Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
node-sqlite3
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
俞永鹏
node-sqlite3
Commits
3ad3bb76
Commit
3ad3bb76
authored
Feb 16, 2011
by
Konstantin Käfer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
blob test
parent
d2647714
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
82 additions
and
0 deletions
+82
-0
blob.test.js
test/blob.test.js
+82
-0
No files found.
test/blob.test.js
0 → 100644
View file @
3ad3bb76
var
sqlite
=
require
(
'sqlite3'
),
Step
=
require
(
'step'
),
fs
=
require
(
'fs'
),
assert
=
require
(
'assert'
)
Buffer
=
require
(
'buffer'
).
Buffer
;
// lots of elmo
var
elmo
=
fs
.
readFileSync
(
__dirname
+
'/support/elmo.png'
,
'binary'
);
var
elmo_str
=
elmo
.
toString
(
'binary'
);
exports
[
'Blob overflow test'
]
=
function
(
beforeExit
)
{
var
db
=
new
sqlite
.
Database
(
''
);
var
total
=
100
;
var
inserted
=
0
;
var
retrieved
=
0
;
db
.
openSync
(
function
(
err
)
{
if
(
err
)
throw
err
;
});
Step
(
function
()
{
var
next
=
this
;
db
.
prepare
(
'CREATE TABLE elmos (image BLOB);'
,
function
(
err
,
statement
)
{
assert
.
isUndefined
(
err
);
statement
.
step
(
next
);
});
},
function
()
{
var
group
=
this
.
group
();
for
(
var
i
=
0
;
i
<
total
;
i
++
)
{
var
next
=
group
();
db
.
prepare
(
'INSERT INTO elmos (image) VALUES (?)'
,
function
(
err
,
statement
)
{
assert
.
isUndefined
(
err
);
statement
.
bind
(
1
,
elmo
,
function
()
{
statement
.
step
(
function
(
err
)
{
assert
.
isUndefined
(
err
);
inserted
++
;
next
();
});
});
});
}
},
function
()
{
var
next
=
this
;
db
.
execute
(
'SELECT COUNT(*) as amount FROM elmos'
,
function
(
err
,
rows
)
{
assert
.
isUndefined
(
err
);
assert
.
eql
(
rows
[
0
].
amount
,
total
);
next
();
});
},
function
()
{
var
next
=
this
;
db
.
prepare
(
'SELECT image FROM elmos;'
,
function
(
err
,
statement
)
{
assert
.
isUndefined
(
err
);
fetch
();
function
fetch
()
{
statement
.
step
(
function
(
err
,
row
)
{
assert
.
isUndefined
(
err
);
if
(
row
)
{
// Not using assert.equal here because it's image data
// and we don't want that in the command line.
assert
.
ok
(
elmo_str
===
row
.
image
);
retrieved
++
;
fetch
();
}
else
{
next
();
}
});
}
});
}
);
beforeExit
(
function
()
{
assert
.
eql
(
inserted
,
total
);
assert
.
eql
(
retrieved
,
total
);
})
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment