Add method that returns if bookmark's ssh is empty
We will use this method in upcoming commit to create client from stored bookmark.
This commit is contained in:
@@ -23,6 +23,9 @@ type Bookmark struct {
|
||||
Ssh shared.SSHInfo `json:"ssh"` // SSH tunnel config
|
||||
}
|
||||
|
||||
func (b Bookmark) SSHInfoIsEmpty() bool {
|
||||
return b.Ssh.User == "" && b.Ssh.Host == "" && b.Ssh.Port == ""
|
||||
}
|
||||
func readServerConfig(path string) (Bookmark, error) {
|
||||
bookmark := Bookmark{}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package bookmarks
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/sosedoff/pgweb/pkg/shared"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
@@ -69,3 +70,22 @@ func Test_ReadBookmarks(t *testing.T) {
|
||||
assert.Equal(t, nil, err)
|
||||
assert.Equal(t, 2, len(bookmarks))
|
||||
}
|
||||
|
||||
func Test_Bookmark_SSHInfoIsEmpty(t *testing.T) {
|
||||
emptySSH := shared.SSHInfo{
|
||||
Host: "",
|
||||
Port: "",
|
||||
User: "",
|
||||
}
|
||||
populatedSSH := shared.SSHInfo{
|
||||
Host: "localhost",
|
||||
Port: "8080",
|
||||
User: "postgres",
|
||||
}
|
||||
|
||||
b := Bookmark{Ssh: emptySSH}
|
||||
assert.True(t, b.SSHInfoIsEmpty())
|
||||
|
||||
b.Ssh = populatedSSH
|
||||
assert.False(t, b.SSHInfoIsEmpty())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user