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
426a2de1
Commit
426a2de1
authored
Feb 14, 2011
by
Konstantin Käfer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update test to work with current version
parent
e81c2c95
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
35 deletions
+60
-35
blob.test.js
test/blob.test.js
+60
-35
No files found.
test/blob.test.js
View file @
426a2de1
var
sqlite
=
require
(
'sqlite3
_bindings
'
),
var
sqlite
=
require
(
'sqlite3'
),
Step
=
require
(
'step'
),
Step
=
require
(
'step'
),
fs
=
require
(
'fs'
),
fs
=
require
(
'fs'
),
assert
=
require
(
'assert'
);
assert
=
require
(
'assert'
)
Buffer
=
require
(
'buffer'
).
Buffer
;
var
db
=
new
sqlite
.
Database
();
// lots of elmo
// lots of elmo
var
elmo
=
fs
.
readFile
(
__dirname
+
'/elmo.png'
,
'binary'
);
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
;
exports
[
'Blob overflow test'
]
=
function
()
{
Step
(
Step
(
function
()
{
function
()
{
db
.
open
(
__dirname
+
'/blobtest.sqlite
'
,
this
);
db
.
open
(
'
'
,
this
);
},
},
function
()
{
function
()
{
db
.
prepare
(
var
next
=
this
;
'CREATE TABLE IF NOT EXISTS elmos ('
db
.
prepare
(
'CREATE TABLE elmos (image BLOB);'
,
function
(
err
,
statement
)
{
+
'image BLOB);'
,
function
(
err
,
statement
)
{
assert
.
isUndefined
(
err
);
statement
.
step
(
this
);
}.
bind
(
this
));
},
function
(
err
)
{
db
.
prepare
(
'INSERT INTO elmos (image) '
+
'VALUES (?)'
,
function
(
err
,
statement
)
{
assert
.
isUndefined
(
err
);
assert
.
isUndefined
(
err
);
statement
.
bind
(
0
,
elmo
);
statement
.
step
(
next
);
statement
.
step
(
this
);
});
}.
bind
(
this
));
},
},
function
()
{
function
()
{
var
group
=
this
.
group
();
var
group
=
this
.
group
();
for
(
var
i
=
0
;
i
<
1000000
;
i
++
)
{
for
(
var
i
=
0
;
i
<
total
;
i
++
)
{
console
.
log
(
'ELMO'
);
var
next
=
group
();
db
.
prepare
(
db
.
prepare
(
'INSERT INTO elmos (image) VALUES (?)'
,
function
(
err
,
statement
)
{
'INSERT INTO elmos (image) '
assert
.
isUndefined
(
err
);
+
'VALUES (?)'
,
statement
.
bind
(
1
,
elmo
,
function
()
{
function
(
err
,
statement
)
{
statement
.
step
(
function
(
err
)
{
Step
(
assert
.
isUndefined
(
err
);
inserted
++
;
next
();
});
});
});
}
},
function
()
{
function
()
{
statement
.
bind
(
0
,
elmo
,
this
);
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
()
{
function
()
{
// DO IT
var
next
=
this
;
statement
.
step
(
group
());
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
{
}.
bind
(
this
)
);
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