The controller plans config, templates and moved providers' provisions, hands bus accounts to the vault and judges the new manifest words, on the feature's SDK and node-engine validator (feature 57, config and provisioning).
54 lines
2.1 KiB
Go
54 lines
2.1 KiB
Go
package catalogue
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// A module may declare its unhealthy urgent, with why; the module check refuses it without why and with any
|
|
// severity but urgent or warning (novox/hq ADR 0355).
|
|
|
|
func TestAnUnhealthyDeclaredUrgentIsUrgent(t *testing.T) {
|
|
m, err := ParseManifest([]byte(`{"module":"mail","version":"1",` +
|
|
`"unhealthy":{"severity":"urgent","why":"mail is refused or stuck for everyone with a mailbox"}}`))
|
|
if err != nil {
|
|
t.Fatalf("a manifest declaring its unhealthy urgent with why was refused: %v", err)
|
|
}
|
|
if !m.UnhealthyIsUrgent() {
|
|
t.Errorf("a manifest declaring its unhealthy urgent reads as not urgent: %+v", m.Unhealthy)
|
|
}
|
|
}
|
|
|
|
func TestAManifestWithoutUnhealthyIsNotUrgent(t *testing.T) {
|
|
m, err := ParseManifest([]byte(`{"module":"notes","version":"1"}`))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if m.UnhealthyIsUrgent() {
|
|
t.Errorf("a manifest saying nothing of its unhealthy reads as urgent")
|
|
}
|
|
warning := Manifest{Module: "notes", Unhealthy: &UnhealthyPolicy{Severity: UnhealthyWarning, Why: "notes wait"}}
|
|
if warning.UnhealthyIsUrgent() || len(warning.unhealthyProblems()) != 0 {
|
|
t.Errorf("a warning said with why reads as urgent or is refused: %v", warning.unhealthyProblems())
|
|
}
|
|
}
|
|
|
|
func TestAnUnhealthyWithoutWhyIsRefused(t *testing.T) {
|
|
for _, why := range []string{"", " "} {
|
|
if problems := (Manifest{Module: "mail", Unhealthy: &UnhealthyPolicy{Severity: UnhealthyUrgent, Why: why}}).unhealthyProblems(); len(problems) == 0 {
|
|
t.Errorf("urgent with why %q was accepted", why)
|
|
}
|
|
}
|
|
if _, err := ParseManifest([]byte(`{"module":"mail","version":"1","unhealthy":{"severity":"urgent"}}`)); err == nil ||
|
|
!strings.Contains(err.Error(), "unhealthy says why") {
|
|
t.Errorf("a manifest declaring its unhealthy urgent without why parsed: %v", err)
|
|
}
|
|
}
|
|
|
|
func TestAnUnhealthySeverityOtherThanUrgentOrWarningIsRefused(t *testing.T) {
|
|
if _, err := ParseManifest([]byte(`{"module":"mail","version":"1","unhealthy":{"severity":"loud","why":"mail stops"}}`)); err == nil ||
|
|
!strings.Contains(err.Error(), `not "loud"`) {
|
|
t.Errorf("a manifest declaring its unhealthy loud parsed: %v", err)
|
|
}
|
|
}
|