mirror of
https://github.com/hanzoai/status.git
synced 2026-10-30 18:21:48 +00:00
White-labelable status monitoring service with all Gatus branding removed. Defaults to neutral "Status" text. Branding is driven entirely by the ui section in config YAML. - Pure Go build (CGO_ENABLED=0, modernc.org/sqlite) - Multi-stage Dockerfile (node frontend + go backend + alpine runtime) - K8s kustomize overlays for hanzo and lux deployments - GitHub Actions CI for GHCR image push - Pre-built Vue frontend with zero upstream branding
54 lines
1.1 KiB
Go
54 lines
1.1 KiB
Go
package ui
|
|
|
|
import (
|
|
"errors"
|
|
"testing"
|
|
)
|
|
|
|
func TestValidateAndSetDefaults(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
config *Config
|
|
wantErr error
|
|
}{
|
|
{
|
|
name: "with-valid-config",
|
|
config: &Config{
|
|
Badge: &Badge{
|
|
ResponseTime: &ResponseTime{Thresholds: []int{50, 200, 300, 500, 750}},
|
|
},
|
|
},
|
|
wantErr: nil,
|
|
},
|
|
{
|
|
name: "with-invalid-threshold-length",
|
|
config: &Config{
|
|
Badge: &Badge{
|
|
ResponseTime: &ResponseTime{Thresholds: []int{50, 200, 300, 500}},
|
|
},
|
|
},
|
|
wantErr: ErrInvalidBadgeResponseTimeConfig,
|
|
},
|
|
{
|
|
name: "with-invalid-thresholds-order",
|
|
config: &Config{
|
|
Badge: &Badge{ResponseTime: &ResponseTime{Thresholds: []int{50, 200, 500, 300, 750}}},
|
|
},
|
|
wantErr: ErrInvalidBadgeResponseTimeConfig,
|
|
},
|
|
{
|
|
name: "with-no-badge-configured", // should give default badge cfg
|
|
config: &Config{},
|
|
wantErr: nil,
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if err := tt.config.ValidateAndSetDefaults(); !errors.Is(err, tt.wantErr) {
|
|
t.Errorf("Expected error %v, got %v", tt.wantErr, err)
|
|
}
|
|
})
|
|
}
|
|
}
|