mirror of
https://github.com/TwiN/gatus.git
synced 2024-11-21 23:43:27 +01:00
f54c45e20e
* 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
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)
|
|
}
|
|
}
|