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 bf8246bc
authored
Feb 26, 2013
by
Sascha Depold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added assertion for error messages
1 parent
feca1473
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
11 deletions
lib/dao-factory.js
spec/buster-helpers.js
spec/dao-factory.spec.js
lib/dao-factory.js
View file @
bf8246b
...
@@ -407,7 +407,7 @@ module.exports = (function() {
...
@@ -407,7 +407,7 @@ module.exports = (function() {
throw
new
Error
(
msg
)
throw
new
Error
(
msg
)
}
}
}
else
{
}
else
{
throw
new
Error
(
'Include malformed. Expected attributes: daoFactory, as'
)
throw
new
Error
(
'Include malformed. Expected attributes: daoFactory, as
!
'
)
}
}
}
else
{
}
else
{
throw
new
Error
(
'Include unexpected. Element has to be either an instance of DAOFactory or an object.'
)
throw
new
Error
(
'Include unexpected. Element has to be either an instance of DAOFactory or an object.'
)
...
...
spec/buster-helpers.js
View file @
bf8246b
...
@@ -2,6 +2,7 @@ const Sequelize = require(__dirname + "/../index")
...
@@ -2,6 +2,7 @@ const Sequelize = require(__dirname + "/../index")
,
DataTypes
=
require
(
__dirname
+
"/../lib/data-types"
)
,
DataTypes
=
require
(
__dirname
+
"/../lib/data-types"
)
,
config
=
require
(
__dirname
+
"/config/config"
)
,
config
=
require
(
__dirname
+
"/config/config"
)
,
fs
=
require
(
'fs'
)
,
fs
=
require
(
'fs'
)
,
buster
=
require
(
"buster"
)
var
BusterHelpers
=
module
.
exports
=
{
var
BusterHelpers
=
module
.
exports
=
{
Sequelize
:
Sequelize
,
Sequelize
:
Sequelize
,
...
@@ -95,5 +96,14 @@ var BusterHelpers = module.exports = {
...
@@ -95,5 +96,14 @@ var BusterHelpers = module.exports = {
}
else
{
}
else
{
throw
new
Error
(
'Undefined expectation for "'
+
dialect
+
'"!'
)
throw
new
Error
(
'Undefined expectation for "'
+
dialect
+
'"!'
)
}
}
},
assertException
:
function
(
block
,
msg
)
{
try
{
block
()
throw
new
Error
(
'Passed function did not throw an error'
)
}
catch
(
e
)
{
buster
.
assert
.
equals
(
e
.
message
,
msg
)
}
}
}
}
}
spec/dao-factory.spec.js
View file @
bf8246b
...
@@ -489,21 +489,21 @@ describe(Helpers.getTestDialectTeaser("DAOFactory"), function() {
...
@@ -489,21 +489,21 @@ describe(Helpers.getTestDialectTeaser("DAOFactory"), function() {
})
})
it
(
'throws an error about unexpected input if include contains a non-object'
,
function
()
{
it
(
'throws an error about unexpected input if include contains a non-object'
,
function
()
{
expect
(
function
()
{
Helpers
.
assertException
(
function
()
{
this
.
Worker
.
find
({
include
:
[
1
]
})
this
.
Worker
.
find
({
include
:
[
1
]
})
}.
bind
(
this
)
).
toThrow
(
)
}.
bind
(
this
)
,
'Include unexpected. Element has to be either an instance of DAOFactory or an object.'
)
})
})
it
(
'throws an error about missing attributes if include contains an object with daoFactory'
,
function
()
{
it
(
'throws an error about missing attributes if include contains an object with daoFactory'
,
function
()
{
expect
(
function
()
{
Helpers
.
assertException
(
function
()
{
this
.
Worker
.
find
({
include
:
[
{
daoFactory
:
this
.
Worker
}
]
})
this
.
Worker
.
find
({
include
:
[
{
daoFactory
:
this
.
Worker
}
]
})
}.
bind
(
this
)
).
toThrow
(
)
}.
bind
(
this
)
,
'Include malformed. Expected attributes: daoFactory, as!'
)
})
})
it
(
'throws an error if included DaoFactory is not associated'
,
function
()
{
it
(
'throws an error if included DaoFactory is not associated'
,
function
()
{
expect
(
function
()
{
Helpers
.
assertException
(
function
()
{
this
.
Worker
.
find
({
include
:
[
this
.
Task
]
})
this
.
Worker
.
find
({
include
:
[
this
.
Task
]
})
}.
bind
(
this
)
).
toThrow
(
)
}.
bind
(
this
)
,
'Task is not associated to Worker!'
)
})
})
it
(
'returns the associated worker via task.worker'
,
function
(
done
)
{
it
(
'returns the associated worker via task.worker'
,
function
(
done
)
{
...
@@ -537,9 +537,9 @@ describe(Helpers.getTestDialectTeaser("DAOFactory"), function() {
...
@@ -537,9 +537,9 @@ describe(Helpers.getTestDialectTeaser("DAOFactory"), function() {
})
})
it
(
'throws an error if included DaoFactory is not associated'
,
function
()
{
it
(
'throws an error if included DaoFactory is not associated'
,
function
()
{
expect
(
function
()
{
Helpers
.
assertException
(
function
()
{
this
.
Task
.
find
({
include
:
[
this
.
Worker
]
})
this
.
Task
.
find
({
include
:
[
this
.
Worker
]
})
}.
bind
(
this
)
).
toThrow
(
)
}.
bind
(
this
)
,
'Worker is not associated to Task!'
)
})
})
it
(
'returns the associated task via worker.task'
,
function
(
done
)
{
it
(
'returns the associated task via worker.task'
,
function
(
done
)
{
...
@@ -573,9 +573,9 @@ describe(Helpers.getTestDialectTeaser("DAOFactory"), function() {
...
@@ -573,9 +573,9 @@ describe(Helpers.getTestDialectTeaser("DAOFactory"), function() {
})
})
it
(
'throws an error if included DaoFactory is not associated'
,
function
()
{
it
(
'throws an error if included DaoFactory is not associated'
,
function
()
{
expect
(
function
()
{
Helpers
.
assertException
(
function
()
{
this
.
Task
.
find
({
include
:
[
this
.
Worker
]
})
this
.
Task
.
find
({
include
:
[
this
.
Worker
]
})
}.
bind
(
this
)
).
toThrow
(
)
}.
bind
(
this
)
,
'Worker is not associated to Task!'
)
})
})
it
(
'returns the associated tasks via worker.tasks'
,
function
(
done
)
{
it
(
'returns the associated tasks via worker.tasks'
,
function
(
done
)
{
...
...
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