Skip to content

Commit

Permalink
test: add test for winrm default values
Browse files Browse the repository at this point in the history
  • Loading branch information
d-strobel committed Oct 16, 2023
1 parent d54347c commit a8cb4e4
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions connection/winrm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,66 @@ func TestNewWinRMClient(t *testing.T) {
}
})
}

func TestNewWinRMClientWithDefaultValues(t *testing.T) {
t.Run("Defaults Used", func(t *testing.T) {
// Test case with minimal configuration, should use default values
config := &WinRMConfig{
WinRMHost: "example.com",
WinRMUsername: "username",
WinRMPassword: "password",
}

client, err := newWinRMClient(config)

if err != nil {
t.Errorf("Expected no error, but got %v", err)
}

if client == nil {
t.Error("Expected a non-nil client, but got nil")
}

// Check that default values were applied
if config.WinRMPort != defaultWinRMPort {
t.Errorf("Expected WinRMPort to be %d, but got %d", defaultWinRMPort, config.WinRMPort)
}

if config.WinRMUseTLS != defaultWinRMUseTLS {
t.Errorf("Expected WinRMUseTLS to be %v, but got %v", defaultWinRMUseTLS, config.WinRMUseTLS)
}

if config.WinRMTimeout != defaultWinRMTimeout {
t.Errorf("Expected WinRMTimeout to be %v, but got %v", defaultWinRMTimeout, config.WinRMTimeout)
}
})

t.Run("TLS Used", func(t *testing.T) {
// Test case with minimal configuration, should use default values
config := &WinRMConfig{
WinRMHost: "example.com",
WinRMUsername: "username",
WinRMPassword: "password",
WinRMUseTLS: true,
}

client, err := newWinRMClient(config)

if err != nil {
t.Errorf("Expected no error, but got %v", err)
}

if client == nil {
t.Error("Expected a non-nil client, but got nil")
}

// Check that default values were applied
if config.WinRMPort != defaultWinRMPortTLS {
t.Errorf("Expected WinRMPort to be %d, but got %d", defaultWinRMPortTLS, config.WinRMPort)
}

if config.WinRMTimeout != defaultWinRMTimeout {
t.Errorf("Expected WinRMTimeout to be %v, but got %v", defaultWinRMTimeout, config.WinRMTimeout)
}
})
}

0 comments on commit a8cb4e4

Please sign in to comment.