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
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
61 deletions
+53
-61
test-affected-rows.js
tests/test-affected-rows.js
+53
-60
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'
);
sys
=
require
(
'sys'
);
fs
=
require
(
'fs'
);
fs
=
require
(
'fs'
);
path
=
require
(
'path'
);
TestSuite
=
require
(
'async-testing/async_testing'
).
TestSuite
;
TestSuite
=
require
(
'async-testing/async_testing'
).
TestSuite
;
sqlite
=
require
(
'sqlite
3_bindings
'
);
sqlite
=
require
(
'sqlite'
);
common
=
require
(
'common'
);
puts
=
sys
.
puts
;
puts
=
sys
.
puts
;
inspect
=
sys
.
inspect
;
inspect
=
sys
.
inspect
;
var
name
=
"Caching of affectedRows"
;
var
name
=
"Caching of affectedRows"
;
var
suite
=
exports
[
name
]
=
new
TestSuite
(
name
);
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
=
[
var
tests
=
[
{
'insert a row with lastinsertedid'
:
{
'insert a row with lastinsertedid'
:
function
(
assert
,
finished
)
{
function
(
assert
,
finished
)
{
var
self
=
this
;
var
self
=
this
;
self
.
db
.
open
(
':memory:'
,
function
(
error
)
{
var
data
=
[
[
'foo 0'
]
function
updateStatementCreated
(
error
,
statement
)
{
,
[
'foo 1'
]
if
(
error
)
throw
error
;
,
[
'foo 2'
]
statement
.
step
(
function
(
error
,
row
)
{
,
[
'foo 3'
]
if
(
error
)
throw
error
;
,
[
'foo 4'
]
assert
.
equal
(
this
.
affectedRows
,
10
,
"Last inserted id should be 10"
);
,
[
'foo 5'
]
,
[
'foo 6'
]
,
[
'foo 7'
]
,
[
'foo 8'
]
,
[
'foo 9'
]
];
finished
();
common
.
createTable
});
(
self
.
db
}
,
'table1'
,
[
{
name
:
'id'
,
type
:
'INT'
}
,
{
name
:
'name'
,
type
:
'TEXT'
}
]
,
function
(
error
)
{
if
(
error
)
throw
error
;
var
updateSQL
=
'UPDATE table1 SET name="o hai"'
;
createTestTable
(
self
.
db
,
common
.
insertMany
function
()
{
(
self
.
db
function
insertRows
(
db
,
count
,
callback
)
{
,
'table1'
var
i
=
count
;
,
[
'name'
]
db
.
prepare
(
'INSERT INTO table1 (name) VALUES ("oh boy")'
,
,
data
function
(
error
,
statement
)
{
,
function
()
{
statement
.
step
(
function
(
error
,
row
)
{
self
.
db
.
prepare
if
(
error
)
throw
error
;
(
updateSQL
assert
.
ok
(
!
row
,
"Row should be unset"
);
,
{
affectedRows
:
true
}
statement
.
reset
();
,
onUpdateStatementCreated
if
(
--
i
)
);
statement
.
step
(
arguments
.
callee
);
else
callback
();
});
});
});
}
}
);
var
updateSQL
function
onUpdateStatementCreated
(
error
,
statement
)
{
=
'UPDATE table1 SET name="o hai"'
;
if
(
error
)
throw
error
;
statement
.
step
(
function
(
error
,
row
)
{
if
(
error
)
throw
error
;
assert
.
equal
(
this
.
affectedRows
,
data
.
length
,
"Last inserted id should be 10"
);
common
.
insertMany
(
self
.
db
,
'table1'
,
finished
();
[
'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
);
});
});
});
}
}
}
}
];
];
...
@@ -92,7 +83,9 @@ var testCount = tests.length;
...
@@ -92,7 +83,9 @@ var testCount = tests.length;
suite
.
setup
(
function
(
finished
,
test
)
{
suite
.
setup
(
function
(
finished
,
test
)
{
this
.
db
=
new
sqlite
.
Database
();
this
.
db
=
new
sqlite
.
Database
();
finished
();
this
.
db
.
open
(
':memory:'
,
function
(
error
)
{
finished
();
});
});
});
suite
.
teardown
(
function
(
finished
)
{
suite
.
teardown
(
function
(
finished
)
{
if
(
this
.
db
)
this
.
db
.
close
(
function
(
error
)
{
if
(
this
.
db
)
this
.
db
.
close
(
function
(
error
)
{
...
...
tests/test-statement-step.js
View file @
82c2a674
...
@@ -52,7 +52,6 @@ var tests = [
...
@@ -52,7 +52,6 @@ var tests = [
,
testRows
,
testRows
,
function
()
{
,
function
()
{
common
.
getResultsStep
(
self
.
db
,
function
(
rows
)
{
common
.
getResultsStep
(
self
.
db
,
function
(
rows
)
{
console
.
log
(
sys
.
inspect
(
arguments
));
assert
.
deepEqual
(
rows
,
testRowsExpected
);
assert
.
deepEqual
(
rows
,
testRowsExpected
);
finished
();
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