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 aff5f1c6
authored
Jan 10, 2014
by
Sascha Depold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test that migrations are correctly undone
1 parent
35cf11c9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
10 deletions
test/sequelize.executable.test.js
test/sequelize.executable.test.js
View file @
aff5f1c
...
...
@@ -209,20 +209,30 @@ describe(Support.getTestDialectTeaser("Executable"), function() {
;(
function
(
flags
)
{
flags
.
forEach
(
function
(
flag
)
{
var
prepare
=
function
(
callback
)
{
var
execBinary
=
function
(
callback
,
_flag
)
{
_flag
=
_flag
||
flag
var
dialect
=
Support
.
getTestDialect
()
,
config
=
require
(
__dirname
+
'/config/config.js'
)
config
.
sqlite
.
storage
=
__dirname
+
"/tmp/test.sqlite"
config
=
_
.
extend
(
config
,
config
[
dialect
],
{
dialect
:
dialect
})
exec
(
"echo '"
+
JSON
.
stringify
(
config
)
+
"' > config/config.json"
,
{
cwd
:
__dirname
+
'/tmp'
},
function
(
error
,
stdout
)
{
exec
(
"../../bin/sequelize "
+
_flag
,
{
cwd
:
__dirname
+
"/tmp"
},
callback
)
})
}
var
prepare
=
function
(
callback
,
options
)
{
options
=
options
||
{}
exec
(
"rm -rf ./*"
,
{
cwd
:
__dirname
+
'/tmp'
},
function
(
error
,
stdout
)
{
exec
(
"../../bin/sequelize --init"
,
{
cwd
:
__dirname
+
'/tmp'
},
function
(
error
,
stdout
)
{
exec
(
"cp ../assets/migrations/*-createPerson.js ./migrations/"
,
{
cwd
:
__dirname
+
'/tmp'
},
function
(
error
,
stdout
)
{
exec
(
"cat ../support.js|sed s,/../,/../../, > ./support.js"
,
{
cwd
:
__dirname
+
'/tmp'
},
function
(
error
,
stdout
)
{
var
dialect
=
Support
.
getTestDialect
()
,
config
=
require
(
__dirname
+
'/config/config.js'
)
config
.
sqlite
.
storage
=
__dirname
+
"/tmp/test.sqlite"
config
=
_
.
extend
(
config
,
config
[
dialect
],
{
dialect
:
dialect
})
exec
(
"echo '"
+
JSON
.
stringify
(
config
)
+
"' > config/config.json"
,
{
cwd
:
__dirname
+
'/tmp'
},
function
(
error
,
stdout
)
{
exec
(
"../../bin/sequelize "
+
flag
,
{
cwd
:
__dirname
+
"/tmp"
},
callback
)
})
if
(
!
options
.
skipExecBinary
)
{
execBinary
(
callback
,
options
.
flag
)
}
})
})
})
...
...
@@ -265,6 +275,34 @@ describe(Support.getTestDialectTeaser("Executable"), function() {
done
()
}.
bind
(
this
))
})
it
(
"is correctly undoing a migration if they have been done yet"
,
function
(
done
)
{
var
sequelize
=
this
.
sequelize
if
(
this
.
sequelize
.
options
.
dialect
===
'sqlite'
)
{
var
options
=
this
.
sequelize
.
options
options
.
storage
=
__dirname
+
"/tmp/test.sqlite"
sequelize
=
new
Support
.
Sequelize
(
""
,
""
,
""
,
options
)
}
prepare
(
function
()
{
sequelize
.
getQueryInterface
().
showAllTables
().
success
(
function
(
tables
)
{
tables
=
tables
.
sort
()
expect
(
tables
).
to
.
have
.
length
(
2
)
expect
(
tables
[
0
]).
to
.
equal
(
"Person"
)
execBinary
(
function
(
err
,
output
)
{
sequelize
.
getQueryInterface
().
showAllTables
().
success
(
function
(
tables
)
{
expect
(
tables
).
to
.
have
.
length
(
1
)
expect
(
tables
[
0
]).
to
.
equal
(
"SequelizeMeta"
)
done
()
})
})
})
}.
bind
(
this
),
{
flag
:
'-m'
})
})
})
})
})([
'--migrate --undo'
,
'-mu'
])
...
...
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