Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
public
/
sequelize
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
不要怂,就是干,撸起袖子干!
Commit cc5ffa4f
authored
Jul 25, 2013
by
Daniel Durante
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added sqlite specific tests
1 parent
ce706174
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
43 deletions
test/sqlite/dao-factory.spec.js → test/sqlite/dao-factory.test.js
test/sqlite/dao.spec.js → test/sqlite/dao.test.js
test/sqlite/query-generator.spec.js → test/sqlite/query-generator.test.js
test/sqlite/test.sqlite
test/sqlite/dao-factory.
spec
.js
→
test/sqlite/dao-factory.
test
.js
View file @
cc5ffa4
...
@@ -10,7 +10,12 @@ var chai = require('chai')
...
@@ -10,7 +10,12 @@ var chai = require('chai')
chai
.
Assertion
.
includeStack
=
true
chai
.
Assertion
.
includeStack
=
true
if
(
dialect
===
'sqlite'
)
{
if
(
dialect
===
'sqlite'
)
{
describe
(
'[SQLITE] DAOFactory'
,
function
()
{
describe
(
'[SQLITE Specific] DAOFactory'
,
function
()
{
after
(
function
(
done
)
{
this
.
sequelize
.
options
.
storage
=
':memory:'
done
()
})
beforeEach
(
function
(
done
)
{
beforeEach
(
function
(
done
)
{
this
.
sequelize
.
options
.
storage
=
dbFile
this
.
sequelize
.
options
.
storage
=
dbFile
this
.
User
=
this
.
sequelize
.
define
(
'User'
,
{
this
.
User
=
this
.
sequelize
.
define
(
'User'
,
{
...
@@ -27,13 +32,13 @@ if (dialect === 'sqlite') {
...
@@ -27,13 +32,13 @@ if (dialect === 'sqlite') {
describe
(
'with storage "'
+
storage
+
'"'
,
function
()
{
describe
(
'with storage "'
+
storage
+
'"'
,
function
()
{
after
(
function
(
done
)
{
after
(
function
(
done
)
{
if
(
storage
===
dbFile
)
{
if
(
storage
===
dbFile
)
{
done
()
require
(
"fs"
).
writeFile
(
dbFile
,
''
,
function
()
{
// require("fs").writeFile(dbFile, '', done)
done
()
})
}
}
})
})
describe
(
'create'
,
function
()
{
describe
(
'create'
,
function
()
{
it
(
'creates a table entry'
,
function
(
done
)
{
it
(
'creates a table entry'
,
function
(
done
)
{
var
self
=
this
var
self
=
this
this
.
User
.
create
({
age
:
21
,
name
:
'John Wayne'
,
bio
:
'noot noot'
}).
success
(
function
(
user
)
{
this
.
User
.
create
({
age
:
21
,
name
:
'John Wayne'
,
bio
:
'noot noot'
}).
success
(
function
(
user
)
{
...
@@ -139,7 +144,7 @@ if (dialect === 'sqlite') {
...
@@ -139,7 +144,7 @@ if (dialect === 'sqlite') {
it
(
"should return all users"
,
function
(
done
)
{
it
(
"should return all users"
,
function
(
done
)
{
this
.
User
.
all
().
on
(
'success'
,
function
(
users
)
{
this
.
User
.
all
().
on
(
'success'
,
function
(
users
)
{
expect
(
users
.
length
).
to
.
equal
(
2
)
expect
(
users
).
to
.
have
.
length
(
2
)
done
()
done
()
})
})
})
})
...
@@ -174,7 +179,7 @@ if (dialect === 'sqlite') {
...
@@ -174,7 +179,7 @@ if (dialect === 'sqlite') {
this
.
User
.
bulkCreate
(
users
).
success
(
function
()
{
this
.
User
.
bulkCreate
(
users
).
success
(
function
()
{
self
.
User
.
max
(
'age'
).
on
(
'success'
,
function
(
min
)
{
self
.
User
.
max
(
'age'
).
on
(
'success'
,
function
(
min
)
{
expect
(
min
).
to
.
equal
(
5
)
;
expect
(
min
).
to
.
equal
(
5
)
done
()
done
()
})
})
})
})
...
...
test/sqlite/dao.
spec
.js
→
test/sqlite/dao.
test
.js
View file @
cc5ffa4
var
buster
=
require
(
"buster"
)
var
chai
=
require
(
'chai'
)
,
Helpers
=
require
(
'../buster-helpers'
)
,
expect
=
chai
.
expect
,
dialect
=
Helpers
.
getTestDialect
(
)
,
Support
=
require
(
__dirname
+
'/../support'
)
,
DataTypes
=
require
(
__dirname
+
"/../../lib/data-types"
)
,
DataTypes
=
require
(
__dirname
+
"/../../lib/data-types"
)
,
dialect
=
Support
.
getTestDialect
()
buster
.
spec
.
expose
()
chai
.
Assertion
.
includeStack
=
true
buster
.
testRunner
.
timeout
=
1000
var
sequelize
=
Helpers
.
createSequelizeInstance
({
dialect
:
dialect
})
if
(
dialect
===
'sqlite'
)
{
if
(
dialect
===
'sqlite'
)
{
describe
(
'[SQLITE] DAO'
,
function
()
{
describe
(
'[SQLITE Specific] DAO'
,
function
()
{
before
(
function
(
done
)
{
beforeEach
(
function
(
done
)
{
var
self
=
this
this
.
User
=
this
.
sequelize
.
define
(
'User'
,
{
this
.
sequelize
=
sequelize
username
:
DataTypes
.
STRING
Helpers
.
clearDatabase
(
this
.
sequelize
,
function
()
{
})
self
.
User
=
sequelize
.
define
(
'User'
,
{
this
.
User
.
sync
({
force
:
true
}).
success
(
function
()
{
username
:
DataTypes
.
STRING
done
()
})
self
.
User
.
sync
({
force
:
true
}).
success
(
done
)
})
})
})
})
...
@@ -32,7 +28,7 @@ if (dialect === 'sqlite') {
...
@@ -32,7 +28,7 @@ if (dialect === 'sqlite') {
self
.
User
.
findAll
({
self
.
User
.
findAll
({
where
:
[
'createdAt > ?'
,
new
Date
(
2012
,
01
,
01
)]
where
:
[
'createdAt > ?'
,
new
Date
(
2012
,
01
,
01
)]
}).
success
(
function
(
users
)
{
}).
success
(
function
(
users
)
{
expect
(
users
.
length
).
toEqual
(
1
)
expect
(
users
).
to
.
have
.
length
(
1
)
done
()
done
()
})
})
})
})
...
...
test/sqlite/query-generator.
spec
.js
→
test/sqlite/query-generator.
test
.js
View file @
cc5ffa4
var
buster
=
require
(
"buster"
)
var
chai
=
require
(
'chai'
)
,
Helpers
=
require
(
'../buster-helpers'
)
,
expect
=
chai
.
expect
,
dialect
=
Helpers
.
getTestDialect
()
,
Support
=
require
(
__dirname
+
'/../support'
)
,
QueryGenerator
=
require
(
"../../lib/dialects/sqlite/query-generator"
)
,
util
=
require
(
"util"
)
,
DataTypes
=
require
(
__dirname
+
"/../../lib/data-types"
)
,
DataTypes
=
require
(
__dirname
+
"/../../lib/data-types"
)
,
dialect
=
Support
.
getTestDialect
()
,
util
=
require
(
"util"
)
,
_
=
require
(
'lodash'
)
,
QueryGenerator
=
require
(
"../../lib/dialects/sqlite/query-generator"
)
buster
.
spec
.
expose
()
chai
.
Assertion
.
includeStack
=
true
buster
.
testRunner
.
timeout
=
1000
var
sequelize
=
Helpers
.
createSequelizeInstance
({
dialect
:
dialect
})
if
(
dialect
===
'sqlite'
)
{
if
(
dialect
===
'sqlite'
)
{
describe
(
'[SQLITE] QueryGenerator'
,
function
()
{
describe
(
'[SQLITE Specific] QueryGenerator'
,
function
()
{
before
(
function
(
done
)
{
beforeEach
(
function
(
done
)
{
var
self
=
this
this
.
User
=
this
.
sequelize
.
define
(
'User'
,
{
this
.
sequelize
=
sequelize
username
:
DataTypes
.
STRING
Helpers
.
clearDatabase
(
this
.
sequelize
,
function
()
{
})
self
.
User
=
sequelize
.
define
(
'User'
,
{
this
.
User
.
sync
({
force
:
true
}).
success
(
function
()
{
username
:
DataTypes
.
STRING
done
()
})
self
.
User
.
sync
({
force
:
true
}).
success
(
done
)
})
})
})
})
...
@@ -229,7 +226,7 @@ if (dialect === 'sqlite') {
...
@@ -229,7 +226,7 @@ if (dialect === 'sqlite') {
}
}
Helpers
.
Sequelize
.
Utils
.
_
.
each
(
suites
,
function
(
tests
,
suiteTitle
)
{
_
.
each
(
suites
,
function
(
tests
,
suiteTitle
)
{
describe
(
suiteTitle
,
function
()
{
describe
(
suiteTitle
,
function
()
{
tests
.
forEach
(
function
(
test
)
{
tests
.
forEach
(
function
(
test
)
{
var
title
=
test
.
title
||
'SQLite correctly returns '
+
test
.
expectation
+
' for '
+
util
.
inspect
(
test
.
arguments
)
var
title
=
test
.
title
||
'SQLite correctly returns '
+
test
.
expectation
+
' for '
+
util
.
inspect
(
test
.
arguments
)
...
@@ -238,7 +235,7 @@ if (dialect === 'sqlite') {
...
@@ -238,7 +235,7 @@ if (dialect === 'sqlite') {
var
context
=
test
.
context
||
{
options
:
{}};
var
context
=
test
.
context
||
{
options
:
{}};
QueryGenerator
.
options
=
context
.
options
QueryGenerator
.
options
=
context
.
options
var
conditions
=
QueryGenerator
[
suiteTitle
].
apply
(
QueryGenerator
,
test
.
arguments
)
var
conditions
=
QueryGenerator
[
suiteTitle
].
apply
(
QueryGenerator
,
test
.
arguments
)
expect
(
conditions
).
to
E
qual
(
test
.
expectation
)
expect
(
conditions
).
to
.
deep
.
e
qual
(
test
.
expectation
)
done
()
done
()
})
})
})
})
...
...
test/sqlite/test.sqlite
View file @
cc5ffa4
Binary files a/test/sqlite/test.sqlite and b/test/sqlite/test.sqlite differ
Binary files a/test/sqlite/test.sqlite and b/test/sqlite/test.sqlite differ
Write
Preview
Markdown
is supported
Attach a file
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 post a comment