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 c26c5f4d
authored
Mar 16, 2015
by
Mick Hansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(test/misc): utils for verifying sequelize has no running/pending queries
1 parent
ce2e86b1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
0 deletions
lib/sequelize.js
test/integration/support.js
lib/sequelize.js
View file @
c26c5f4
...
@@ -198,6 +198,17 @@ module.exports = (function() {
...
@@ -198,6 +198,17 @@ module.exports = (function() {
this
.
importCache
=
{};
this
.
importCache
=
{};
this
.
test
=
{
$trackRunningQueries
:
false
,
$runningQueries
:
0
,
trackRunningQueries
:
function
()
{
this
.
$trackRunningQueries
=
true
;
},
verifyNoRunningQueries
:
function
()
{
if
(
this
.
$runningQueries
>
0
)
throw
new
Error
(
'Expected 0 running queries. '
+
this
.
$runningQueries
+
' queries still running'
);
}
};
Sequelize
.
runHooks
(
'afterInit'
,
this
);
Sequelize
.
runHooks
(
'afterInit'
,
this
);
};
};
...
@@ -731,6 +742,10 @@ module.exports = (function() {
...
@@ -731,6 +742,10 @@ module.exports = (function() {
return
Promise
.
reject
(
options
.
transaction
.
finished
+
' has been called on this transaction, you can no longer use it'
);
return
Promise
.
reject
(
options
.
transaction
.
finished
+
' has been called on this transaction, you can no longer use it'
);
}
}
if
(
this
.
test
.
$trackRunningQueries
)
{
this
.
test
.
$runningQueries
++
;
}
return
Promise
.
resolve
(
return
Promise
.
resolve
(
options
.
transaction
?
options
.
transaction
.
connection
:
self
.
connectionManager
.
getConnection
(
options
)
options
.
transaction
?
options
.
transaction
.
connection
:
self
.
connectionManager
.
getConnection
(
options
)
).
then
(
function
(
connection
)
{
).
then
(
function
(
connection
)
{
...
@@ -739,6 +754,10 @@ module.exports = (function() {
...
@@ -739,6 +754,10 @@ module.exports = (function() {
if
(
options
.
transaction
)
return
;
if
(
options
.
transaction
)
return
;
return
self
.
connectionManager
.
releaseConnection
(
connection
);
return
self
.
connectionManager
.
releaseConnection
(
connection
);
});
});
}).
finally
(
function
()
{
if
(
self
.
test
.
$trackRunningQueries
)
{
self
.
test
.
$runningQueries
--
;
}
});
});
};
};
...
...
test/integration/support.js
View file @
c26c5f4
...
@@ -20,7 +20,12 @@ before(function() {
...
@@ -20,7 +20,12 @@ before(function() {
});
});
beforeEach
(
function
()
{
beforeEach
(
function
()
{
this
.
sequelize
.
test
.
trackRunningQueries
();
return
Support
.
clearDatabase
(
this
.
sequelize
);
return
Support
.
clearDatabase
(
this
.
sequelize
);
});
});
afterEach
(
function
()
{
this
.
sequelize
.
test
.
verifyNoRunningQueries
();
});
module
.
exports
=
Support
;
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