Builds: design 47 G A-107, A-109, A-110 Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
32 lines
714 B
Go
32 lines
714 B
Go
package catalogue
|
|
|
|
import (
|
|
"encoding/json"
|
|
"testing"
|
|
)
|
|
|
|
func strSliceEqual(a, b []string) bool {
|
|
if len(a) != len(b) {
|
|
return false
|
|
}
|
|
for i := range a {
|
|
if a[i] != b[i] {
|
|
return false
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
|
|
func TestProcessBusReadsServesAndRefusesUnknownKeys(t *testing.T) {
|
|
var b ProcessBus
|
|
if err := json.Unmarshal([]byte(`{"serves":["seat:mesh-broker.snapshot-get","seat:mesh-broker.list"]}`), &b); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if !strSliceEqual(b.Serves, []string{"seat:mesh-broker.snapshot-get", "seat:mesh-broker.list"}) {
|
|
t.Errorf("serves = %v", b.Serves)
|
|
}
|
|
if err := json.Unmarshal([]byte(`{"holds":["x"]}`), &ProcessBus{}); err == nil {
|
|
t.Error("an unknown key was accepted")
|
|
}
|
|
}
|