Move bookmark default port parsing to readServerConfig func
This commit is contained in:
parent
59018287de
commit
0510634db7
@ -49,6 +49,11 @@ func readServerConfig(path string) (Bookmark, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_, err = toml.Decode(string(buff), &bookmark)
|
_, err = toml.Decode(string(buff), &bookmark)
|
||||||
|
|
||||||
|
if bookmark.Port == 0 {
|
||||||
|
bookmark.Port = 5432
|
||||||
|
}
|
||||||
|
|
||||||
return bookmark, err
|
return bookmark, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,9 +106,5 @@ func GetBookmark(bookmarkPath string, bookmarkName string) (Bookmark, error) {
|
|||||||
return Bookmark{}, fmt.Errorf("couldn't find a bookmark with name %s", bookmarkName)
|
return Bookmark{}, fmt.Errorf("couldn't find a bookmark with name %s", bookmarkName)
|
||||||
}
|
}
|
||||||
|
|
||||||
if bookmark.Port == 0 {
|
|
||||||
bookmark.Port = 5432
|
|
||||||
}
|
|
||||||
|
|
||||||
return bookmark, nil
|
return bookmark, nil
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ func Test_Bookmark_URL(t *testing.T) {
|
|||||||
assert.Equal(t, nil, err)
|
assert.Equal(t, nil, err)
|
||||||
assert.Equal(t, "postgres://username:password@host:port/database?sslmode=disable", bookmark.Url)
|
assert.Equal(t, "postgres://username:password@host:port/database?sslmode=disable", bookmark.Url)
|
||||||
assert.Equal(t, "", bookmark.Host)
|
assert.Equal(t, "", bookmark.Host)
|
||||||
assert.Equal(t, 0, bookmark.Port)
|
assert.Equal(t, 5432, bookmark.Port)
|
||||||
assert.Equal(t, "", bookmark.User)
|
assert.Equal(t, "", bookmark.User)
|
||||||
assert.Equal(t, "", bookmark.Database)
|
assert.Equal(t, "", bookmark.Database)
|
||||||
assert.Equal(t, "", bookmark.Ssl)
|
assert.Equal(t, "", bookmark.Ssl)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user