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 8ed1bc3e
authored
Jan 19, 2014
by
Sascha Depold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests for transaction manager
1 parent
656da3ef
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
72 additions
and
0 deletions
test/transaction-manager.test.js
test/transaction-manager.test.js
0 → 100644
View file @
8ed1bc3
var
chai
=
require
(
'chai'
)
,
expect
=
chai
.
expect
,
Support
=
require
(
__dirname
+
'/support'
)
,
TransactionManager
=
require
(
__dirname
+
'/../lib/transaction-manager'
)
describe
(
Support
.
getTestDialectTeaser
(
"TransactionManager"
),
function
()
{
beforeEach
(
function
()
{
this
.
transactionManager
=
new
TransactionManager
(
this
.
sequelize
)
})
describe
(
'getConnectorManager'
,
function
()
{
describe
(
'if no uuid is passed'
,
function
()
{
it
(
'uses the default connector'
,
function
()
{
var
connectorManager
=
this
.
transactionManager
.
getConnectorManager
()
expect
(
connectorManager
.
config
.
uuid
).
to
.
equal
(
'default'
)
})
it
(
'uses the pooling configuration of sequelize'
,
function
()
{
var
connectorManager
=
this
.
transactionManager
.
getConnectorManager
()
,
self
=
this
if
(
Support
.
getTestDialect
()
!==
'sqlite'
)
{
expect
(
this
.
sequelize
.
config
.
pool
.
maxConnections
).
to
.
equal
(
5
)
}
Object
.
keys
(
this
.
sequelize
.
config
.
pool
||
{}).
forEach
(
function
(
key
)
{
expect
(
connectorManager
.
config
.
pool
[
key
]).
to
.
equal
(
self
.
sequelize
.
config
.
pool
[
key
])
})
})
})
describe
(
'if the passed uuid is not equal to "default"'
,
function
()
{
it
(
'uses the non-default connector'
,
function
()
{
var
connectorManager
=
this
.
transactionManager
.
getConnectorManager
(
'a-uuid'
)
expect
(
connectorManager
.
config
.
uuid
).
to
.
equal
(
'a-uuid'
)
})
it
(
'creates a new connector manager'
,
function
()
{
this
.
transactionManager
.
getConnectorManager
()
expect
(
Object
.
keys
(
this
.
transactionManager
.
connectorManagers
).
length
).
to
.
equal
(
1
)
this
.
transactionManager
.
getConnectorManager
(
'a-uuid'
)
expect
(
Object
.
keys
(
this
.
transactionManager
.
connectorManagers
).
length
).
to
.
equal
(
2
)
this
.
transactionManager
.
getConnectorManager
(
'a-uuid'
)
expect
(
Object
.
keys
(
this
.
transactionManager
.
connectorManagers
).
length
).
to
.
equal
(
2
)
})
it
(
'treats the connector managers as singleton'
,
function
()
{
var
connectorManager1
=
this
.
transactionManager
.
getConnectorManager
(
'a-uuid'
)
,
connectorManager2
=
this
.
transactionManager
.
getConnectorManager
(
'a-uuid'
)
expect
(
connectorManager1
).
to
.
equal
(
connectorManager2
)
})
it
(
'uses the pooling configuration of sequelize but with disabled replication and forced to one connection'
,
function
()
{
var
connectorManager
=
this
.
transactionManager
.
getConnectorManager
(
'a-uuid'
)
,
self
=
this
if
(
Support
.
getTestDialect
()
!==
'sqlite'
)
{
expect
(
this
.
sequelize
.
config
.
pool
.
maxConnections
).
to
.
equal
(
5
)
}
Object
.
keys
(
this
.
sequelize
.
config
.
pool
||
{}).
forEach
(
function
(
key
)
{
if
(
key
!==
'maxConnections'
)
{
expect
(
connectorManager
.
config
.
pool
[
key
]).
to
.
equal
(
self
.
sequelize
.
config
.
pool
[
key
])
}
})
expect
(
connectorManager
.
config
.
pool
.
maxConnections
).
to
.
equal
(
0
)
})
})
})
})
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