-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve error output for missing or malformed '-database' and '-source' parameters #88
Conversation
Pull Request Test Coverage Report for Build 164
💛 - Coveralls |
6768262
to
b2ab621
Compare
b2ab621
to
7fc4692
Compare
I'm not sure if this is the correct place to validate parameters. If all of the confusion is with the migrate CLI, then we only need to validate the parameters in the CLI. e.g. ensure that source/path is specified |
I'm not sure. I haven't used the as a library yet. But I would imagine that usage like in godoc_vfs/vfs_example_test.go where we call m, err := migrate.NewWithSourceInstance("godoc-vfs", d, "database://foobar")
... would suffer from the same problems if |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
env variable ends up being empty for any reason
Good point. Let's validate the URLs then.
util.go
Outdated
@@ -44,14 +44,34 @@ func suint(n int) uint { | |||
} | |||
|
|||
var errNoScheme = fmt.Errorf("no scheme") | |||
var errEmpty = fmt.Errorf("cannot be empty") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename to errEmptyURL
and use the string "URL cannot be empty"
.
Also, use errors.New()
instead of fmt.Errorf()
if string formatting isn't used.
util_test.go
Outdated
cases := []struct { | ||
name string | ||
given string | ||
expectErr error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re-structure this to test valid URLs as well
util_test.go
Outdated
func TestSourceSchemeFromUrl(t *testing.T) { | ||
cases := []struct { | ||
name string | ||
given string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename to urlStr
37e8240
to
d22e0c4
Compare
d22e0c4
to
1121910
Compare
@dhui Updated. |
Related to #89
The current output only reads
"no scheme"
which is not really helpful.Updates mattes/migrate#270
Updates mattes/migrate#317