diff --git a/data/bookmark_with_ssh.toml b/data/bookmark_with_ssh.toml new file mode 100644 index 0000000..193c63a --- /dev/null +++ b/data/bookmark_with_ssh.toml @@ -0,0 +1,12 @@ +host = "localhost" +port = 5432 +user = "postgres" +database = "mydatabase" +ssl = "disable" + +[SSH] +host = "ssh-host" +user = "ssh-user" +password = "ssh-password" +key = "/path/to/key-file" +keypassword = "key-file-password" diff --git a/pkg/bookmarks/manager_test.go b/pkg/bookmarks/manager_test.go index 9b72b98..f9e1506 100644 --- a/pkg/bookmarks/manager_test.go +++ b/pkg/bookmarks/manager_test.go @@ -12,7 +12,7 @@ func TestManagerList(t *testing.T) { num int err string }{ - {"../../data", 3, ""}, + {"../../data", 4, ""}, {"../../data/bookmark.toml", 0, "is not a directory"}, {"../../data2", 0, ""}, {"", 0, ""}, @@ -32,7 +32,12 @@ func TestManagerList(t *testing.T) { func TestManagerListIDs(t *testing.T) { ids, err := NewManager("../../data").ListIDs() assert.NoError(t, err) - assert.Equal(t, []string{"bookmark", "bookmark_invalid_ssl", "bookmark_url"}, ids) + assert.Equal(t, []string{ + "bookmark", + "bookmark_invalid_ssl", + "bookmark_url", + "bookmark_with_ssh", + }, ids) } func TestManagerGet(t *testing.T) { @@ -80,6 +85,19 @@ func Test_readBookmark(t *testing.T) { assert.Equal(t, "", b.Password) }) + t.Run("with ssh options", func(t *testing.T) { + b, err := readBookmark("../../data/bookmark_with_ssh.toml") + assert.NoError(t, err) + assert.NotNil(t, b.SSH) + + sshc := b.SSH + assert.Equal(t, "ssh-host", sshc.Host) + assert.Equal(t, "ssh-user", sshc.User) + assert.Equal(t, "ssh-password", sshc.Password) + assert.Equal(t, "/path/to/key-file", sshc.Key) + assert.Equal(t, "key-file-password", sshc.KeyPassword) + }) + t.Run("invalid ssl", func(t *testing.T) { b, err := readBookmark("../../data/bookmark_invalid_ssl.toml") assert.NoError(t, err)