From 58ae69de0b68fc66bff5419d5359db53e1388249 Mon Sep 17 00:00:00 2001 From: Dan Sosedoff Date: Tue, 3 Oct 2017 23:00:18 -0500 Subject: [PATCH 1/2] Fix panics when sshinfo is not set on bookmarks --- pkg/bookmarks/bookmarks.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/bookmarks/bookmarks.go b/pkg/bookmarks/bookmarks.go index 758eeb1..7bddc09 100644 --- a/pkg/bookmarks/bookmarks.go +++ b/pkg/bookmarks/bookmarks.go @@ -25,7 +25,7 @@ type Bookmark struct { } func (b Bookmark) SSHInfoIsEmpty() bool { - return b.Ssh.User == "" && b.Ssh.Host == "" && b.Ssh.Port == "" + return b.Ssh == nil || b.Ssh.User == "" && b.Ssh.Host == "" && b.Ssh.Port == "" } func (b Bookmark) ConvertToOptions() command.Options { From 277e2d6cd8bf11e2ad4b0c84e29fa5f706d89e11 Mon Sep 17 00:00:00 2001 From: Dan Sosedoff Date: Tue, 3 Oct 2017 23:03:02 -0500 Subject: [PATCH 2/2] Add an extra test to verify SSHinfoIsEmpty does not panic --- pkg/bookmarks/bookmarks_test.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/bookmarks/bookmarks_test.go b/pkg/bookmarks/bookmarks_test.go index 5584edc..61221a4 100644 --- a/pkg/bookmarks/bookmarks_test.go +++ b/pkg/bookmarks/bookmarks_test.go @@ -106,7 +106,10 @@ func Test_Bookmark_SSHInfoIsEmpty(t *testing.T) { User: "postgres", } - b := Bookmark{Ssh: emptySSH} + b := Bookmark{Ssh: nil} + assert.True(t, b.SSHInfoIsEmpty()) + + b = Bookmark{Ssh: emptySSH} assert.True(t, b.SSHInfoIsEmpty()) b.Ssh = populatedSSH