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 394b5ac0
authored
Jul 23, 2013
by
Sascha Depold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
configuration test
1 parent
125a80c3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
170 additions
and
0 deletions
test/config/config.js
test/configuration.test.js
test/config/config.js
0 → 100644
View file @
394b5ac
module
.
exports
=
{
username
:
"root"
,
password
:
null
,
database
:
'sequelize_test'
,
host
:
'127.0.0.1'
,
pool
:
{
maxConnections
:
5
,
maxIdleTime
:
30000
},
rand
:
function
()
{
return
parseInt
(
Math
.
random
()
*
999
,
10
)
},
//make maxIdleTime small so that tests exit promptly
mysql
:
{
username
:
"root"
,
password
:
null
,
database
:
'sequelize_test'
,
host
:
'127.0.0.1'
,
port
:
3306
,
pool
:
{
maxConnections
:
5
,
maxIdleTime
:
30
}
},
sqlite
:
{
},
postgres
:
{
database
:
'sequelize_test'
,
username
:
"postgres"
,
port
:
5432
,
pool
:
{
maxConnections
:
5
,
maxIdleTime
:
30
}
}
}
test/configuration.test.js
0 → 100644
View file @
394b5ac
var
chai
=
require
(
'chai'
)
,
expect
=
chai
.
expect
,
semver
=
require
(
"semver"
)
,
config
=
require
(
__dirname
+
"/config/config"
)
,
Utils
=
require
(
__dirname
+
'/../lib/utils'
)
,
Support
=
require
(
__dirname
+
'/support'
)
,
dialect
=
Support
.
getTestDialect
()
,
Sequelize
=
require
(
__dirname
+
'/../index'
)
,
noDomains
=
semver
.
lt
(
process
.
version
,
'0.8.0'
)
describe
(
Support
.
getTestDialectTeaser
(
"Configuration"
),
function
()
{
describe
(
'Connections problems should fail with a nice message'
,
function
()
{
it
(
'when we don\'t have the correct server details'
,
function
(
done
)
{
if
(
noDomains
===
true
)
{
console
.
log
(
'WARNING: Configuration specs requires NodeJS version >= 0.8 for full compatibility'
)
expect
(
''
).
toEqual
(
''
)
// Silence Buster!
return
done
()
}
(
function
()
{
var
sequelizeSpecific2
=
new
Sequelize
(
config
[
dialect
].
database
,
config
[
dialect
].
username
,
config
[
dialect
].
password
,
{
storage
:
'/path/to/no/where/land'
,
logging
:
false
,
host
:
'0.0.0.1'
,
port
:
config
[
dialect
].
port
,
dialect
:
dialect
})
,
domain
=
require
(
'domain'
)
,
d
=
domain
.
create
()
d
.
on
(
'error'
,
function
(
err
){
expect
(
err
).
to
.
match
(
/Failed to find
(
.*
?)
Please double check your settings
\.
/
)
d
.
remove
(
sequelizeSpecific2
.
query
)
done
()
})
d
.
run
(
function
(){
d
.
add
(
sequelizeSpecific2
.
query
)
sequelizeSpecific2
.
query
(
'select 1 as hello'
)
.
success
(
function
(){})
})
})()
})
it
(
'when we don\'t have the correct login information'
,
function
(
done
)
{
if
(
dialect
!==
"postgres"
&&
dialect
!==
"postgres-native"
&&
dialect
!==
"mysql"
)
{
console
.
log
(
'This dialect doesn\'t support me :('
)
expect
(
''
).
toEqual
(
''
)
// Silence Buster
return
done
()
}
if
(
noDomains
===
true
)
{
console
.
log
(
'WARNING: Configuration specs requires NodeJS version >= 0.8 for full compatibility'
)
expect
(
''
).
toEqual
(
''
)
// Silence Buster!
return
done
()
}
(
function
()
{
var
sequelizeSpecific1
=
new
Sequelize
(
config
[
dialect
].
database
,
config
[
dialect
].
username
,
'fakepass123'
,
{
logging
:
false
,
host
:
config
[
dialect
].
host
,
port
:
1
,
dialect
:
dialect
})
,
domain
=
require
(
'domain'
)
,
d
=
domain
.
create
()
d
.
on
(
'error'
,
function
(
err
){
expect
(
err
).
to
.
match
(
/^Failed to authenticate/
)
d
.
remove
(
sequelizeSpecific1
.
query
)
done
()
})
d
.
run
(
function
(){
d
.
add
(
sequelizeSpecific1
.
query
)
sequelizeSpecific1
.
query
(
'select 1 as hello'
)
.
success
(
function
(){})
})
})()
})
it
(
'when we don\'t have a valid dialect.'
,
function
(
done
)
{
expect
(
function
()
{
new
Sequelize
(
config
[
dialect
].
database
,
config
[
dialect
].
username
,
config
[
dialect
].
password
,
{
host
:
'0.0.0.1'
,
port
:
config
[
dialect
].
port
,
dialect
:
undefined
})
}).
to
.
throw
(
'The dialect undefined is not supported.'
)
done
()
})
})
describe
(
'Instantiation with a URL string'
,
function
()
{
it
(
'should accept username, password, host, port, and database'
,
function
()
{
var
sequelize
=
new
Sequelize
(
'mysql://user:pass@example.com:9821/dbname'
)
var
config
=
sequelize
.
config
var
options
=
sequelize
.
options
expect
(
options
.
dialect
).
to
.
equal
(
'mysql'
)
expect
(
config
.
database
).
to
.
equal
(
'dbname'
)
expect
(
config
.
host
).
to
.
equal
(
'example.com'
)
expect
(
config
.
username
).
to
.
equal
(
'user'
)
expect
(
config
.
password
).
to
.
equal
(
'pass'
)
expect
(
config
.
port
).
to
.
equal
(
'9821'
)
})
it
(
'should work with no authentication options'
,
function
()
{
var
sequelize
=
new
Sequelize
(
'mysql://example.com:9821/dbname'
)
var
config
=
sequelize
.
config
expect
(
config
.
username
).
to
.
equal
(
undefined
)
expect
(
config
.
password
).
to
.
equal
(
null
)
})
it
(
'should use the default port when no other is specified'
,
function
()
{
var
sequelize
=
new
Sequelize
(
'mysql://example.com/dbname'
)
var
config
=
sequelize
.
config
// The default port should be set
expect
(
config
.
port
).
to
.
equal
(
3306
)
})
})
describe
(
'Intantiation with arguments'
,
function
()
{
it
(
'should accept two parameters (database, username)'
,
function
()
{
var
sequelize
=
new
Sequelize
(
'dbname'
,
'root'
)
var
config
=
sequelize
.
config
expect
(
config
.
database
).
to
.
equal
(
'dbname'
)
expect
(
config
.
username
).
to
.
equal
(
'root'
)
})
it
(
'should accept three parameters (database, username, password)'
,
function
()
{
var
sequelize
=
new
Sequelize
(
'dbname'
,
'root'
,
'pass'
)
var
config
=
sequelize
.
config
expect
(
config
.
database
).
to
.
equal
(
'dbname'
)
expect
(
config
.
username
).
to
.
equal
(
'root'
)
expect
(
config
.
password
).
to
.
equal
(
'pass'
)
})
it
(
'should accept four parameters (database, username, password, options)'
,
function
()
{
var
sequelize
=
new
Sequelize
(
'dbname'
,
'root'
,
'pass'
,
{
port
:
999
})
var
config
=
sequelize
.
config
expect
(
config
.
database
).
to
.
equal
(
'dbname'
)
expect
(
config
.
username
).
to
.
equal
(
'root'
)
expect
(
config
.
password
).
to
.
equal
(
'pass'
)
expect
(
config
.
port
).
to
.
equal
(
999
)
})
})
})
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