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 5c3f4c38
authored
Dec 31, 2013
by
Simon Townsend
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test added, sqlite url support
1 parent
16b8f467
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
84 additions
and
1 deletions
bin/sequelize
test/sequelize.executable.test.js
test/support.js
bin/sequelize
View file @
5c3f4c3
...
@@ -98,6 +98,10 @@ var parseDbUrl = function(urlString) {
...
@@ -98,6 +98,10 @@ var parseDbUrl = function(urlString) {
config
.
host
=
urlParts
.
hostname
;
config
.
host
=
urlParts
.
hostname
;
config
.
port
=
urlParts
.
port
;
config
.
port
=
urlParts
.
port
;
if
(
config
.
dialect
===
'sqlite'
)
{
config
.
storage
=
'/'
+
config
.
database
;
}
if
(
urlParts
.
auth
)
{
if
(
urlParts
.
auth
)
{
config
.
username
=
urlParts
.
auth
.
split
(
':'
)[
0
]
config
.
username
=
urlParts
.
auth
.
split
(
':'
)[
0
]
config
.
password
=
urlParts
.
auth
.
split
(
':'
)[
1
]
config
.
password
=
urlParts
.
auth
.
split
(
':'
)[
1
]
...
@@ -105,7 +109,7 @@ var parseDbUrl = function(urlString) {
...
@@ -105,7 +109,7 @@ var parseDbUrl = function(urlString) {
}
catch
(
e
)
{
}
catch
(
e
)
{
throw
new
Error
(
'Error parsing url: '
+
url
);
throw
new
Error
(
'Error parsing url: '
+
url
);
}
}
return
config
return
config
};
};
...
...
test/sequelize.executable.test.js
View file @
5c3f4c3
...
@@ -206,4 +206,70 @@ describe(Support.getTestDialectTeaser("Executable"), function() {
...
@@ -206,4 +206,70 @@ describe(Support.getTestDialectTeaser("Executable"), function() {
})
})
})
})
})([
'--migrate'
,
'-m'
])
})([
'--migrate'
,
'-m'
])
;(
function
(
flags
)
{
flags
.
forEach
(
function
(
flag
)
{
var
prepare
=
function
(
callback
)
{
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
})
var
url
=
Support
.
getTestUrl
(
config
);
exec
(
"echo '"
+
JSON
.
stringify
(
config
)
+
"' > config/config.json"
,
{
cwd
:
__dirname
+
'/tmp'
},
function
(
error
,
stdout
)
{
exec
(
"../../bin/sequelize -m "
+
flag
+
" "
+
url
,
{
cwd
:
__dirname
+
"/tmp"
},
callback
)
})
})
})
})
})
}
describe
(
flag
,
function
()
{
it
(
"creates a SequelizeMeta table"
,
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
[
1
]).
to
.
equal
(
"SequelizeMeta"
)
done
()
})
}.
bind
(
this
))
})
it
(
"creates the respective table via url"
,
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"
)
done
()
})
}.
bind
(
this
))
})
})
})
})([
'--url'
,
'-U'
])
})
})
test/support.js
View file @
5c3f4c3
...
@@ -137,6 +137,19 @@ var Support = {
...
@@ -137,6 +137,19 @@ var Support = {
}
}
return
"["
+
dialect
.
toUpperCase
()
+
"] "
+
moduleName
return
"["
+
dialect
.
toUpperCase
()
+
"] "
+
moduleName
},
getTestUrl
:
function
(
config
)
{
var
url
,
dbConfig
=
config
[
config
.
dialect
];
if
(
config
.
dialect
===
'sqlite'
)
{
url
=
'sqlite://'
+
dbConfig
.
storage
;
}
else
{
url
=
config
.
dialect
+
"://"
+
dbConfig
.
username
+
"@"
+
dbConfig
.
host
+
":"
+
dbConfig
.
port
+
"/"
+
dbConfig
.
database
;
}
return
url
;
}
}
}
}
...
...
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