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 5e794684
authored
Jan 04, 2015
by
Jan Aagaard Meier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Slight rewrite of cls tests
1 parent
7e06e0c9
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
7 deletions
test/cls.test.js
test/cls.test.js
View file @
5e79468
...
...
@@ -7,20 +7,22 @@ var chai = require('chai')
,
Support
=
require
(
__dirname
+
'/support'
)
,
Sequelize
=
Support
.
Sequelize
,
Promise
=
Sequelize
.
Promise
,
cls
=
require
(
'continuation-local-storage'
);
,
cls
=
require
(
'continuation-local-storage'
)
,
current
=
Support
.
sequelize
;
chai
.
config
.
includeStack
=
true
;
describe
(
Support
.
getTestDialectTeaser
(
"Continuation local storage"
),
function
()
{
before
(
function
()
{
return
Support
.
prepareTransactionTest
(
Support
.
createSequelizeInstance
({
this
.
sequelize
=
Support
.
createSequelizeInstance
({
namespace
:
cls
.
createNamespace
(
'sequelize'
)
})).
bind
(
this
).
then
(
function
(
sequelize
)
{
this
.
sequelize
=
sequelize
;
});
});
beforeEach
(
function
()
{
return
Support
.
prepareTransactionTest
(
this
.
sequelize
).
bind
(
this
).
then
(
function
(
sequelize
)
{
this
.
sequelize
=
sequelize
;
this
.
ns
=
cls
.
getNamespace
(
'sequelize'
);
this
.
User
=
this
.
sequelize
.
define
(
'user'
,
{
...
...
@@ -28,6 +30,7 @@ describe(Support.getTestDialectTeaser("Continuation local storage"), function ()
});
return
this
.
sequelize
.
sync
({
force
:
true
});
});
});
var
autoCallback
=
function
autoCallback
(
sequelize
,
cb
)
{
return
sequelize
.
transaction
(
cb
);
...
...
@@ -40,6 +43,7 @@ describe(Support.getTestDialectTeaser("Continuation local storage"), function ()
});
};
if
(
current
.
dialect
.
supports
.
transactions
)
{
[
autoCallback
,
thenCallback
].
forEach
(
function
(
cb
)
{
describe
(
cb
.
name
,
function
()
{
describe
(
'context'
,
function
()
{
...
...
@@ -58,6 +62,8 @@ describe(Support.getTestDialectTeaser("Continuation local storage"), function ()
return
Promise
.
resolve
();
}),
function
()
{
expect
(
t1id
).
to
.
be
.
ok
;
expect
(
t2id
).
to
.
be
.
ok
;
expect
(
t1id
).
not
.
to
.
equal
(
t2id
);
}
);
...
...
@@ -93,12 +99,21 @@ describe(Support.getTestDialectTeaser("Continuation local storage"), function ()
});
});
// Wait for 400 ms - should be enough time to get everything set up
return
Promise
.
delay
(
400
).
bind
(
this
).
then
(
function
()
{
expect
(
transactionSetup
).
to
.
be
.
ok
;
return
new
Promise
(
function
(
resolve
)
{
// Wait for the transaction to be setup
var
interval
=
setInterval
(
function
()
{
if
(
transactionSetup
)
{
clearInterval
(
interval
);
resolve
();
}
},
200
);
}).
bind
(
this
).
then
(
function
()
{
expect
(
transactionEnded
).
not
.
to
.
be
.
ok
;
expect
(
this
.
ns
.
get
(
'transaction'
)).
not
.
to
.
be
.
ok
;
// Just to make sure it didn't change between our last check and the assertion
expect
(
transactionEnded
).
not
.
to
.
be
.
ok
;
});
});
...
...
@@ -126,4 +141,5 @@ describe(Support.getTestDialectTeaser("Continuation local storage"), function ()
});
});
});
}
});
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