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 95843f45
authored
Sep 05, 2014
by
ryanking
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add unit test, findOrCreate() meets error will block sequelize, issue 2238
1 parent
ba4de68e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
0 deletions
test/dao-factory/create.test.js
test/dao-factory/create.test.js
View file @
95843f4
...
...
@@ -31,6 +31,10 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
this
.
Account
=
this
.
sequelize
.
define
(
'Account'
,
{
accountName
:
DataTypes
.
STRING
});
this
.
Student
=
this
.
sequelize
.
define
(
'Student'
,
{
no
:
{
type
:
DataTypes
.
INTEGER
,
primaryKey
:
true
},
name
:
{
type
:
DataTypes
.
STRING
,
allowNull
:
false
},
})
return
this
.
sequelize
.
sync
({
force
:
true
});
});
...
...
@@ -133,6 +137,38 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
})
})
it
(
"should release transaction when meeting errors"
,
function
(
done
){
var
self
=
this
var
test
=
function
(
times
)
{
times
=
times
||
0
if
(
times
>
10
)
{
return
true
// stop trying
}
/*without name, trigger ValidationError */
return
self
.
Student
.
findOrCreate
({
where
:{
no
:
1
},
defaults
:{}})
.
timeout
(
1000
)
.
catch
(
Promise
.
TimeoutError
,
function
(
e
){
throw
new
Error
(
e
)
})
.
then
(
function
(){
return
true
})
.
catch
(
Sequelize
.
ValidationError
,
function
(
err
){
return
test
(
times
+
1
)
})
}
test
()
.
then
(
function
(){
done
()
})
.
catch
(
function
(
err
){
done
(
err
)
})
})
describe
(
'several concurrent calls'
,
function
()
{
it
(
'works with a transaction'
,
function
()
{
return
this
.
sequelize
.
transaction
().
bind
(
this
).
then
(
function
(
transaction
)
{
...
...
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