mirror of
https://github.com/TwiN/gatus.git
synced 2025-03-13 14:48:17 +01:00
26 lines
686 B
Go
26 lines
686 B
Go
|
package core
|
||
|
|
||
|
import (
|
||
|
"errors"
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
func TestSSH_validate(t *testing.T) {
|
||
|
ssh := &SSH{}
|
||
|
if err := ssh.validate(); err == nil {
|
||
|
t.Error("expected an error")
|
||
|
} else if !errors.Is(err, ErrEndpointWithoutSSHUsername) {
|
||
|
t.Errorf("expected error to be '%v', got '%v'", ErrEndpointWithoutSSHUsername, err)
|
||
|
}
|
||
|
ssh.Username = "username"
|
||
|
if err := ssh.validate(); err == nil {
|
||
|
t.Error("expected an error")
|
||
|
} else if !errors.Is(err, ErrEndpointWithoutSSHPassword) {
|
||
|
t.Errorf("expected error to be '%v', got '%v'", ErrEndpointWithoutSSHPassword, err)
|
||
|
}
|
||
|
ssh.Password = "password"
|
||
|
if err := ssh.validate(); err != nil {
|
||
|
t.Errorf("expected no error, got '%v'", err)
|
||
|
}
|
||
|
}
|