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 c9d6aff7
authored
Jul 24, 2013
by
Daniel Durante
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed support.js as it's no longer required, and improved Makefile.
1 parent
ea98944e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
129 deletions
Makefile
test/support.js
Makefile
View file @
c9d6aff
REPORTER
?=
dot
TESTS
=
$(
shell
find ./test/
*
-name
"*.test.js"
)
test
:
sqlite
:
DIALECT
=
sqlite
@
./node_modules/mocha/bin/mocha
\
--colors
\
--reporter
$(REPORTER)
\
$(
shell
find ./test/
*
-name
"*.test.js"
)
$(
TESTS
)
.PHONY
:
test
mysql
:
DIALECT
=
mysql
@
./node_modules/mocha/bin/mocha
\
--colors
\
--reporter
$(REPORTER)
\
$(TESTS)
.PHONY
:
sqlite mysql
test/support.js
deleted
100644 → 0
View file @
ea98944
var
fs
=
require
(
'fs'
)
,
Sequelize
=
require
(
__dirname
+
"/../index"
)
,
DataTypes
=
require
(
__dirname
+
"/../lib/data-types"
)
,
config
=
require
(
__dirname
+
"/config/config"
)
var
Support
=
{
Sequelize
:
Sequelize
,
initTests
:
function
(
options
)
{
var
sequelize
=
this
.
createSequelizeInstance
(
options
)
this
.
clearDatabase
(
sequelize
,
function
()
{
if
(
options
.
context
)
{
options
.
context
.
sequelize
=
sequelize
}
if
(
options
.
beforeComplete
)
{
options
.
beforeComplete
(
sequelize
,
DataTypes
)
}
if
(
options
.
onComplete
)
{
options
.
onComplete
(
sequelize
,
DataTypes
)
}
})
},
createSequelizeInstance
:
function
(
options
)
{
options
=
options
||
{}
options
.
dialect
=
options
.
dialect
||
'mysql'
options
.
logging
=
(
options
.
hasOwnProperty
(
'logging'
)
?
options
.
logging
:
false
)
options
.
pool
=
options
.
pool
||
config
.
pool
var
sequelizeOptions
=
{
logging
:
options
.
logging
,
dialect
:
options
.
dialect
,
port
:
options
.
port
||
process
.
env
.
SEQ_PORT
||
config
[
options
.
dialect
].
port
,
pool
:
options
.
pool
}
if
(
!!
options
.
host
)
{
sequelizeOptions
.
host
=
options
.
host
}
if
(
!!
options
.
define
)
{
sequelizeOptions
.
define
=
options
.
define
}
if
(
process
.
env
.
DIALECT
===
'postgres-native'
)
{
sequelizeOptions
.
native
=
true
}
return
this
.
getSequelizeInstance
(
process
.
env
.
SEQ_DB
||
config
[
options
.
dialect
].
database
,
process
.
env
.
SEQ_USER
||
process
.
env
.
SEQ_USERNAME
||
config
[
options
.
dialect
].
username
,
process
.
env
.
SEQ_PW
||
process
.
env
.
SEQ_PASSWORD
||
config
[
options
.
dialect
].
password
,
sequelizeOptions
)
},
getSequelizeInstance
:
function
(
db
,
user
,
pass
,
options
)
{
return
new
Sequelize
(
db
,
user
,
pass
,
options
)
},
clearDatabase
:
function
(
sequelize
,
callback
)
{
sequelize
.
getQueryInterface
()
.
dropAllTables
()
.
success
(
function
()
{
sequelize
.
daoFactoryManager
.
daos
=
[]
callback
&&
callback
()
})
.
error
(
function
(
err
)
{
console
.
log
(
err
)
})
},
getSupportedDialects
:
function
()
{
return
fs
.
readdirSync
(
__dirname
+
'/../lib/dialects'
).
filter
(
function
(
file
)
{
return
((
file
.
indexOf
(
'.js'
)
===
-
1
)
&&
(
file
.
indexOf
(
'abstract'
)
===
-
1
))
})
},
checkMatchForDialects
:
function
(
dialect
,
value
,
expectations
)
{
if
(
!!
expectations
[
dialect
])
{
expect
(
value
).
to
.
match
(
expectations
[
dialect
])
}
else
{
throw
new
Error
(
'Undefined expectation for "'
+
dialect
+
'"!'
)
}
},
getTestDialect
:
function
()
{
var
envDialect
=
process
.
env
.
DIALECT
||
'mysql'
if
(
envDialect
===
'postgres-native'
)
{
envDialect
=
'postgres'
}
if
(
this
.
getSupportedDialects
().
indexOf
(
envDialect
)
===
-
1
)
{
throw
new
Error
(
'The dialect you have passed is unknown. Did you really mean: '
+
envDialect
)
}
return
envDialect
},
getTestDialectTeaser
:
function
(
moduleName
)
{
var
dialect
=
this
.
getTestDialect
()
if
(
process
.
env
.
DIALECT
===
'postgres-native'
)
{
dialect
=
'postgres-native'
}
return
"["
+
dialect
.
toUpperCase
()
+
"] "
+
moduleName
}
}
var
sequelize
=
Support
.
createSequelizeInstance
({
dialect
:
Support
.
getTestDialect
()
})
before
(
function
(
done
)
{
this
.
sequelize
=
sequelize
done
()
})
afterEach
(
function
(
done
)
{
Support
.
clearDatabase
(
this
.
sequelize
,
done
)
})
module
.
exports
=
Support
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