gatus/core/ssh_test.go
TwiN f54c45e20e
feat: Implement push-based external endpoints (#724)
* refactor: Move SSH outside of endpoint.go
* refactor: Use pointers for Alert receivers
* feat: Implement push-based external endpoints
* Fix failing tests
* Validate external endpoints on start
* Add tests for external endpoints
* refactor some error equality checks
* Improve docs and refactor some code
* Fix UI-related issues with external endpoints
2024-04-08 21:00:40 -04:00

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)
}
}