Skip to content

Commit

Permalink
test: add test for connection
Browse files Browse the repository at this point in the history
  • Loading branch information
d-strobel committed Oct 15, 2023
1 parent 552eb29 commit 4473130
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions connection/connection_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package connection

import (
"testing"

"github.com/stretchr/testify/assert"
)

func TestNewConnectionErrorMessages(t *testing.T) {
t.Run("Error - Neither WinRM nor SSH", func(t *testing.T) {
conf := &Config{}

_, err := New(conf)

assert.Error(t, err)
assert.Contains(t, err.Error(), "one of WinRMConfig and SSHConfig must be set")
})

t.Run("Error - Both WinRM and SSH", func(t *testing.T) {
winRMConfig := &WinRMConfig{
WinRMUsername: "test",
WinRMPassword: "test",
WinRMHost: "test",
}

sshConfig := &SSHConfig{
SSHUsername: "test",
SSHPassword: "test",
SSHHost: "test",
}

conf := &Config{
WinRM: winRMConfig,
SSH: sshConfig,
}

_, err := New(conf)

assert.Error(t, err)
assert.Contains(t, err.Error(), "only one of WinRMConfig and SSHConfig must be set")
})
}

0 comments on commit 4473130

Please sign in to comment.