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 4ab48f75
authored
Mar 28, 2014
by
Sascha Depold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Another test for transactions with concurrency
1 parent
93b0daa1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
1 deletions
test/sequelize.transaction.test.js
test/sequelize.transaction.test.js
View file @
4ab48f7
...
...
@@ -4,7 +4,8 @@ var chai = require('chai')
,
Transaction
=
require
(
__dirname
+
'/../lib/transaction'
)
describe
(
Support
.
getTestDialectTeaser
(
"Sequelize#transaction"
),
function
()
{
this
.
timeout
(
4000
);
this
.
timeout
(
4000
)
describe
(
'success'
,
function
()
{
it
(
"gets triggered once a transaction has been successfully committed"
,
function
(
done
)
{
this
...
...
@@ -147,4 +148,49 @@ describe(Support.getTestDialectTeaser("Sequelize#transaction"), function () {
})
})
})
describe
(
'concurrency'
,
function
()
{
describe
(
'having tables with uniqueness constraints'
,
function
()
{
beforeEach
(
function
(
done
)
{
var
self
=
this
Support
.
prepareTransactionTest
(
this
.
sequelize
,
function
(
sequelize
)
{
self
.
sequelize
=
sequelize
self
.
Model
=
sequelize
.
define
(
'Model'
,
{
name
:
{
type
:
Support
.
Sequelize
.
STRING
,
unique
:
true
}
},
{
timestamps
:
false
})
self
.
Model
.
sync
({
force
:
true
})
.
success
(
function
()
{
done
()
})
})
})
it
(
"triggers the error event for the second transactions"
,
function
(
done
)
{
var
self
=
this
this
.
sequelize
.
transaction
(
function
(
t1
)
{
self
.
sequelize
.
transaction
(
function
(
t2
)
{
self
.
Model
.
create
({
name
:
'omnom'
},
{
transaction
:
t1
})
.
success
(
function
(
m1
)
{
self
.
Model
.
create
({
name
:
'omnom'
},
{
transaction
:
t2
})
.
error
(
function
(
err
)
{
expect
(
err
).
to
.
be
.
defined
done
()
})
setTimeout
(
function
()
{
t1
.
commit
()
},
100
)
})
})
})
})
})
})
})
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