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 e329f903
authored
Mar 10, 2014
by
Thanasis Polychronakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix DAO-create tests with new validation expectations
1 parent
31c340bd
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
8 deletions
lib/dao-validator.js
test/dao-factory/create.test.js
lib/dao-validator.js
View file @
e329f90
...
@@ -361,7 +361,7 @@ DaoValidator.prototype._validateSchema = function(rawAttribute,
...
@@ -361,7 +361,7 @@ DaoValidator.prototype._validateSchema = function(rawAttribute,
var
error
=
new
sequelizeError
.
ValidationError
(
field
+
' cannot be null'
)
var
error
=
new
sequelizeError
.
ValidationError
(
field
+
' cannot be null'
)
error
.
path
=
field
error
.
path
=
field
error
.
value
=
value
error
.
value
=
value
error
.
type
=
'notNull Violation'
error
.
type
=
error
.
message
=
'notNull Violation'
if
(
!
this
.
errors
.
hasOwnProperty
(
field
))
{
if
(
!
this
.
errors
.
hasOwnProperty
(
field
))
{
this
.
errors
[
field
]
=
[];
this
.
errors
[
field
]
=
[];
}
}
...
...
test/dao-factory/create.test.js
View file @
e329f90
...
@@ -376,21 +376,33 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
...
@@ -376,21 +376,33 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
UserNull
.
create
({
username
:
'foo2'
,
smth
:
null
}).
error
(
function
(
err
)
{
UserNull
.
create
({
username
:
'foo2'
,
smth
:
null
}).
error
(
function
(
err
)
{
expect
(
err
).
to
.
exist
expect
(
err
).
to
.
exist
expect
(
err
.
smth
[
0
].
path
).
to
.
equal
(
'smth'
);
if
(
Support
.
dialectIsMySQL
())
{
if
(
Support
.
dialectIsMySQL
())
{
// We need to allow two different errors for MySQL, see:
// We need to allow two different errors for MySQL, see:
// http://dev.mysql.com/doc/refman/5.0/en/server-sql-mode.html#sqlmode_strict_trans_tables
// http://dev.mysql.com/doc/refman/5.0/en/server-sql-mode.html#sqlmode_strict_trans_tables
expect
(
err
.
message
).
to
.
match
(
/
(
Column 'smth' cannot be null|Field 'smth' doesn't have a default value
)
/
)
expect
(
err
.
smth
[
0
].
message
).
to
.
match
(
/notNull Violation
/
)
}
}
else
if
(
dialect
===
"sqlite"
)
{
else
if
(
dialect
===
"sqlite"
)
{
expect
(
err
.
message
).
to
.
match
(
/.*SQLITE_CONSTRAINT.*
/
)
expect
(
err
.
smth
[
0
].
message
).
to
.
match
(
/notNull Violation
/
)
}
else
{
}
else
{
expect
(
err
.
message
).
to
.
match
(
/.*column "smth" violates not-null.*
/
)
expect
(
err
.
smth
[
0
].
message
).
to
.
match
(
/notNull Violation
/
)
}
}
done
()
})
})
})
it
(
"raises an error if created object breaks definition contraints"
,
function
(
done
)
{
var
UserNull
=
this
.
sequelize
.
define
(
'UserWithNonNullSmth'
,
{
username
:
{
type
:
Sequelize
.
STRING
,
unique
:
true
},
smth
:
{
type
:
Sequelize
.
STRING
,
allowNull
:
false
}
})
this
.
sequelize
.
options
.
omitNull
=
false
UserNull
.
sync
({
force
:
true
}).
success
(
function
()
{
UserNull
.
create
({
username
:
'foo'
,
smth
:
'foo'
}).
success
(
function
()
{
UserNull
.
create
({
username
:
'foo'
,
smth
:
'foo'
}).
success
(
function
()
{
UserNull
.
create
({
username
:
'foo'
,
smth
:
'bar'
}).
error
(
function
(
err
)
{
UserNull
.
create
({
username
:
'foo'
,
smth
:
'bar'
}).
error
(
function
(
err
)
{
expect
(
err
).
to
.
exist
expect
(
err
).
to
.
exist
if
(
dialect
===
"sqlite"
)
{
if
(
dialect
===
"sqlite"
)
{
expect
(
err
.
message
).
to
.
match
(
/.*SQLITE_CONSTRAINT.*/
)
expect
(
err
.
message
).
to
.
match
(
/.*SQLITE_CONSTRAINT.*/
)
}
}
...
@@ -399,13 +411,11 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
...
@@ -399,13 +411,11 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
}
else
{
}
else
{
expect
(
err
.
message
).
to
.
match
(
/.*duplicate key value violates unique constraint.*/
)
expect
(
err
.
message
).
to
.
match
(
/.*duplicate key value violates unique constraint.*/
)
}
}
done
()
done
()
})
})
})
})
})
})
})
})
})
it
(
"raises an error if saving an empty string into a column allowing null or URL"
,
function
(
done
)
{
it
(
"raises an error if saving an empty string into a column allowing null or URL"
,
function
(
done
)
{
var
StringIsNullOrUrl
=
this
.
sequelize
.
define
(
'StringIsNullOrUrl'
,
{
var
StringIsNullOrUrl
=
this
.
sequelize
.
define
(
'StringIsNullOrUrl'
,
{
...
@@ -940,7 +950,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
...
@@ -940,7 +950,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
})
})
})
})
it
.
only
(
'emits an error when validate is set to true'
,
function
(
done
)
{
it
(
'emits an error when validate is set to true'
,
function
(
done
)
{
var
Tasks
=
this
.
sequelize
.
define
(
'Task'
,
{
var
Tasks
=
this
.
sequelize
.
define
(
'Task'
,
{
name
:
{
name
:
{
type
:
Sequelize
.
STRING
,
type
:
Sequelize
.
STRING
,
...
...
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