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
82c2a674
Commit
82c2a674
authored
Sep 28, 2010
by
Orlando Vazquez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up tests
parent
2e80b78b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
56 deletions
+48
-56
test-affected-rows.js
tests/test-affected-rows.js
+48
-55
test-statement-step.js
tests/test-statement-step.js
+0
-1
No files found.
tests/test-affected-rows.js
View file @
82c2a674
path
=
require
(
'path'
);
require
.
paths
.
unshift
(
path
.
join
(
__dirname
,
'lib'
));
sys
=
require
(
'sys'
);
fs
=
require
(
'fs'
);
path
=
require
(
'path'
);
TestSuite
=
require
(
'async-testing/async_testing'
).
TestSuite
;
sqlite
=
require
(
'sqlite
3_bindings
'
);
sqlite
=
require
(
'sqlite'
);
common
=
require
(
'common'
);
puts
=
sys
.
puts
;
inspect
=
sys
.
inspect
;
var
name
=
"Caching of affectedRows"
;
var
suite
=
exports
[
name
]
=
new
TestSuite
(
name
);
function
createTestTable
(
db
,
callback
)
{
db
.
prepare
(
'CREATE TABLE table1 (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT)'
,
function
(
error
,
createStatement
)
{
if
(
error
)
throw
error
;
createStatement
.
step
(
function
(
error
,
row
)
{
if
(
error
)
throw
error
;
callback
();
});
});
}
var
tests
=
[
{
'insert a row with lastinsertedid'
:
function
(
assert
,
finished
)
{
var
self
=
this
;
self
.
db
.
open
(
':memory:'
,
function
(
error
)
{
function
updateStatementCreated
(
error
,
statement
)
{
if
(
error
)
throw
error
;
statement
.
step
(
function
(
error
,
row
)
{
var
data
=
[
[
'foo 0'
]
,
[
'foo 1'
]
,
[
'foo 2'
]
,
[
'foo 3'
]
,
[
'foo 4'
]
,
[
'foo 5'
]
,
[
'foo 6'
]
,
[
'foo 7'
]
,
[
'foo 8'
]
,
[
'foo 9'
]
];
common
.
createTable
(
self
.
db
,
'table1'
,
[
{
name
:
'id'
,
type
:
'INT'
}
,
{
name
:
'name'
,
type
:
'TEXT'
}
]
,
function
(
error
)
{
if
(
error
)
throw
error
;
assert
.
equal
(
this
.
affectedRows
,
10
,
"Last inserted id should be 10"
);
var
updateSQL
=
'UPDATE table1 SET name="o hai"'
;
finished
();
common
.
insertMany
(
self
.
db
,
'table1'
,
[
'name'
]
,
data
,
function
()
{
self
.
db
.
prepare
(
updateSQL
,
{
affectedRows
:
true
}
,
onUpdateStatementCreated
);
});
}
);
createTestTable
(
self
.
db
,
function
()
{
function
insertRows
(
db
,
count
,
callback
)
{
var
i
=
count
;
db
.
prepare
(
'INSERT INTO table1 (name) VALUES ("oh boy")'
,
function
(
error
,
statement
)
{
function
onUpdateStatementCreated
(
error
,
statement
)
{
if
(
error
)
throw
error
;
statement
.
step
(
function
(
error
,
row
)
{
if
(
error
)
throw
error
;
assert
.
ok
(
!
row
,
"Row should be unset"
);
statement
.
reset
();
if
(
--
i
)
statement
.
step
(
arguments
.
callee
);
else
callback
();
});
});
}
var
updateSQL
=
'UPDATE table1 SET name="o hai"'
;
assert
.
equal
(
this
.
affectedRows
,
data
.
length
,
"Last inserted id should be 10"
);
common
.
insertMany
(
self
.
db
,
'table1'
,
[
'name'
],
[[
'o hai'
],
[
'o hai'
],
[
'o hai'
],
[
'o hai'
],
[
'o hai'
],
[
'o hai'
],
[
'o hai'
],
[
'o hai'
],
[
'o hai'
],
[
'o hai'
]],
function
()
{
self
.
db
.
prepare
(
updateSQL
,
{
affectedRows
:
true
}
,
updateStatementCreated
);
});
});
finished
();
});
}
}
}
];
// order matters in our tests
...
...
@@ -92,7 +83,9 @@ var testCount = tests.length;
suite
.
setup
(
function
(
finished
,
test
)
{
this
.
db
=
new
sqlite
.
Database
();
this
.
db
.
open
(
':memory:'
,
function
(
error
)
{
finished
();
});
});
suite
.
teardown
(
function
(
finished
)
{
if
(
this
.
db
)
this
.
db
.
close
(
function
(
error
)
{
...
...
tests/test-statement-step.js
View file @
82c2a674
...
...
@@ -52,7 +52,6 @@ var tests = [
,
testRows
,
function
()
{
common
.
getResultsStep
(
self
.
db
,
function
(
rows
)
{
console
.
log
(
sys
.
inspect
(
arguments
));
assert
.
deepEqual
(
rows
,
testRowsExpected
);
finished
();
});
...
...
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