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
This commit is contained in:
51
core/endpoint_common_test.go
Normal file
51
core/endpoint_common_test.go
Normal file
@ -0,0 +1,51 @@
|
||||
package core
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
"github.com/TwiN/gatus/v5/alerting/alert"
|
||||
)
|
||||
|
||||
func TestValidateEndpointNameGroupAndAlerts(t *testing.T) {
|
||||
scenarios := []struct {
|
||||
name string
|
||||
group string
|
||||
alerts []*alert.Alert
|
||||
expectedErr error
|
||||
}{
|
||||
{
|
||||
name: "n",
|
||||
group: "g",
|
||||
alerts: []*alert.Alert{{Type: "slack"}},
|
||||
},
|
||||
{
|
||||
name: "n",
|
||||
alerts: []*alert.Alert{{Type: "slack"}},
|
||||
},
|
||||
{
|
||||
group: "g",
|
||||
alerts: []*alert.Alert{{Type: "slack"}},
|
||||
expectedErr: ErrEndpointWithNoName,
|
||||
},
|
||||
{
|
||||
name: "\"",
|
||||
alerts: []*alert.Alert{{Type: "slack"}},
|
||||
expectedErr: ErrEndpointWithInvalidNameOrGroup,
|
||||
},
|
||||
{
|
||||
name: "n",
|
||||
group: "\\",
|
||||
alerts: []*alert.Alert{{Type: "slack"}},
|
||||
expectedErr: ErrEndpointWithInvalidNameOrGroup,
|
||||
},
|
||||
}
|
||||
for _, scenario := range scenarios {
|
||||
t.Run(scenario.name, func(t *testing.T) {
|
||||
err := validateEndpointNameGroupAndAlerts(scenario.name, scenario.group, scenario.alerts)
|
||||
if !errors.Is(err, scenario.expectedErr) {
|
||||
t.Errorf("expected error to be %v but got %v", scenario.expectedErr, err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user