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 3229b061
authored
Feb 12, 2015
by
Mick Hansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add a few logging option tests
1 parent
6f46f980
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
87 additions
and
1 deletions
lib/model.js
lib/promise.js
test/integration/associations/belongs-to.test.js
test/integration/instance/update.test.js
test/integration/model/create.test.js
test/integration/model/find.test.js
test/integration/model/findAll.test.js
lib/model.js
View file @
3229b06
...
...
@@ -731,7 +731,7 @@ module.exports = (function() {
return
this
.
QueryInterface
.
select
(
this
,
this
.
getTableName
(
options
),
options
,
Utils
.
_
.
defaults
({
hasJoin
:
hasJoin
,
tableNames
:
Object
.
keys
(
tableNames
)
},
queryOptions
,
{
transaction
:
options
.
transaction
}));
},
queryOptions
,
{
transaction
:
options
.
transaction
,
logging
:
options
.
logging
}));
}).
tap
(
function
(
results
)
{
if
(
options
.
hooks
)
{
return
this
.
runHooks
(
'afterFind'
,
results
,
options
);
...
...
lib/promise.js
View file @
3229b06
...
...
@@ -117,6 +117,8 @@ SequelizePromise.all = function (promises) {
* @deprecated
*/
Promise
.
prototype
.
on
=
function
(
evt
,
fct
)
{
deprecated
(
'on() is deprecated and will be removed in 2.1, please use promise-style instead or use logging: fn in method options for method sql log'
);
if
(
evt
===
'success'
)
{
this
.
then
(
fct
);
}
...
...
test/integration/associations/belongs-to.test.js
View file @
3229b06
'use strict'
;
var
chai
=
require
(
'chai'
)
,
sinon
=
require
(
'sinon'
)
,
expect
=
chai
.
expect
,
Support
=
require
(
__dirname
+
'/../support'
)
,
DataTypes
=
require
(
__dirname
+
'/../../../lib/data-types'
)
...
...
@@ -127,6 +128,25 @@ describe(Support.getTestDialectTeaser('BelongsTo'), function() {
expect
(
user
).
to
.
be
.
ok
;
});
});
it
(
'should support logging'
,
function
()
{
var
spy
=
sinon
.
spy
();
var
User
=
this
.
sequelize
.
define
(
'user'
,
{})
,
Project
=
this
.
sequelize
.
define
(
'project'
,
{});
User
.
belongsTo
(
Project
);
return
this
.
sequelize
.
sync
({
force
:
true
}).
bind
(
this
).
then
(
function
()
{
return
User
.
create
({});
}).
then
(
function
(
user
)
{
return
user
.
getProject
({
logging
:
spy
});
}).
then
(
function
()
{
expect
(
spy
.
called
).
to
.
be
.
ok
;
});
});
});
describe
(
'setAssociation'
,
function
()
{
...
...
@@ -232,6 +252,24 @@ describe(Support.getTestDialectTeaser('BelongsTo'), function() {
});
});
it
(
'should support logging'
,
function
()
{
var
User
=
this
.
sequelize
.
define
(
'UserXYZ'
,
{
username
:
DataTypes
.
STRING
})
,
Task
=
this
.
sequelize
.
define
(
'TaskXYZ'
,
{
title
:
DataTypes
.
STRING
})
,
spy
=
sinon
.
spy
();
Task
.
belongsTo
(
User
);
return
this
.
sequelize
.
sync
({
force
:
true
}).
then
(
function
()
{
return
User
.
create
().
then
(
function
(
user
)
{
return
Task
.
create
({}).
then
(
function
(
task
)
{
return
task
.
setUserXYZ
(
user
,
{
logging
:
spy
}).
then
(
function
()
{
expect
(
spy
.
called
).
to
.
be
.
ok
;
});
});
});
});
});
it
(
'should not clobber atributes'
,
function
(
done
)
{
var
Comment
=
this
.
sequelize
.
define
(
'comment'
,
{
text
:
DataTypes
.
STRING
...
...
test/integration/instance/update.test.js
View file @
3229b06
'use strict'
;
var
chai
=
require
(
'chai'
)
,
sinon
=
require
(
'sinon'
)
,
Sequelize
=
require
(
'../../../index'
)
,
expect
=
chai
.
expect
,
Support
=
require
(
__dirname
+
'/../support'
)
...
...
@@ -386,5 +387,15 @@ describe(Support.getTestDialectTeaser('Instance'), function() {
});
});
});
it
(
'should support logging'
,
function
()
{
var
spy
=
sinon
.
spy
();
return
this
.
User
.
create
({}).
then
(
function
(
user
)
{
return
user
.
update
({
username
:
'yolo'
},
{
logging
:
spy
}).
then
(
function
()
{
expect
(
spy
.
called
).
to
.
be
.
ok
;
});
});
});
});
});
test/integration/model/create.test.js
View file @
3229b06
'use strict'
;
var
chai
=
require
(
'chai'
)
,
sinon
=
require
(
'sinon'
)
,
Sequelize
=
require
(
'../../../index'
)
,
Promise
=
Sequelize
.
Promise
,
expect
=
chai
.
expect
...
...
@@ -1590,4 +1591,14 @@ describe(Support.getTestDialectTeaser('Model'), function() {
});
});
});
it
(
'should support logging'
,
function
()
{
var
spy
=
sinon
.
spy
();
return
this
.
User
.
create
({},
{
logging
:
spy
}).
then
(
function
()
{
expect
(
spy
.
called
).
to
.
be
.
ok
;
});
});
});
test/integration/model/find.test.js
View file @
3229b06
'use strict'
;
var
chai
=
require
(
'chai'
)
,
sinon
=
require
(
'sinon'
)
,
Sequelize
=
require
(
'../../../index'
)
,
Promise
=
Sequelize
.
Promise
,
expect
=
chai
.
expect
...
...
@@ -1036,5 +1037,16 @@ describe(Support.getTestDialectTeaser('Model'), function() {
});
});
});
it
(
'should support logging'
,
function
()
{
var
spy
=
sinon
.
spy
();
return
this
.
User
.
findOne
({
where
:
{},
logging
:
spy
}).
then
(
function
()
{
expect
(
spy
.
called
).
to
.
be
.
ok
;
});
});
});
});
test/integration/model/findAll.test.js
View file @
3229b06
'use strict'
;
var
chai
=
require
(
'chai'
)
,
sinon
=
require
(
'sinon'
)
,
Sequelize
=
require
(
'../../../index'
)
,
expect
=
chai
.
expect
,
Support
=
require
(
__dirname
+
'/../support'
)
...
...
@@ -1542,4 +1543,15 @@ describe(Support.getTestDialectTeaser('Model'), function() {
});
});
});
it
(
'should support logging'
,
function
()
{
var
spy
=
sinon
.
spy
();
return
this
.
User
.
findAll
({
where
:
{},
logging
:
spy
}).
then
(
function
()
{
expect
(
spy
.
called
).
to
.
be
.
ok
;
});
});
});
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