Skip to content

Commit

Permalink
Move bookmark default port parsing to readServerConfig func
Browse files Browse the repository at this point in the history
  • Loading branch information
sosedoff committed Nov 16, 2016
1 parent 5901828 commit 0510634
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions pkg/bookmarks/bookmarks.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ func readServerConfig(path string) (Bookmark, error) {
}

_, err = toml.Decode(string(buff), &bookmark)

if bookmark.Port == 0 {
bookmark.Port = 5432
}

return bookmark, err
}

Expand Down Expand Up @@ -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)
}

if bookmark.Port == 0 {
bookmark.Port = 5432
}

return bookmark, nil
}
2 changes: 1 addition & 1 deletion pkg/bookmarks/bookmarks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func Test_Bookmark_URL(t *testing.T) {
assert.Equal(t, nil, err)
assert.Equal(t, "postgres://username:password@host:port/database?sslmode=disable", bookmark.Url)
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.Database)
assert.Equal(t, "", bookmark.Ssl)
Expand Down

0 comments on commit 0510634

Please sign in to comment.