The gate reads a mover's class from its catalog entry; a module that names none is a leaf. Builds: design 47 H2 §810, §814; H-A-394 (1)
38 lines
1.8 KiB
Go
38 lines
1.8 KiB
Go
package catalogue
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
)
|
|
|
|
// Design 47 H2 §812, §814: the validator reads every state, log and objects entry of a manifest that names no cap, in
|
|
// the old sections and in requires alike; a capped entry, and an entry of another template, is none of them.
|
|
func TestAManifestSaysEachKeptStoreThatNamesNoCap(t *testing.T) {
|
|
m, err := decodeForTest([]byte(`{"module":"x","version":"1",
|
|
"state":["seen",{"name":"held","max-mib":8}],
|
|
"logs":[{"name":"acts"},{"name":"kept","max-mib":64}],
|
|
"objects":[{"name":"outputs","max-mib":256}],
|
|
"requires":[{"name":"performed","storage":"key-value","template":"state","options":{"history":1}},
|
|
{"name":"taken","storage":"key-value","template":"state","options":{"max-mib":8,"key-ttl":true}},
|
|
{"name":"archives","storage":"object-store","template":"objects"},
|
|
{"name":"finding-events","storage":"stream","template":"events"}]}`))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
want := []Uncapped{{Name: "seen", Kind: "state", OldSection: true}, {Name: "acts", Kind: "log", OldSection: true},
|
|
{Name: "performed", Kind: "state"}, {Name: "archives", Kind: "objects"}}
|
|
if got := m.UncappedStores(); !reflect.DeepEqual(got, want) {
|
|
t.Fatalf("the uncapped stores are %+v, want %+v", got, want)
|
|
}
|
|
}
|
|
|
|
// Design 47 H2 §810 (H-A-394): a manifest says its class, core or leaf; one that names none is a leaf.
|
|
func TestAManifestSaysItsClassAndNoneIsALeaf(t *testing.T) {
|
|
for raw, leaf := range map[string]bool{`"class":"core",`: false, `"class":"leaf",`: true, ``: true} {
|
|
m, err := decodeForTest([]byte(`{` + raw + `"module":"x","version":"1"}`))
|
|
if err != nil || m.Leaf() != leaf || m.UnknownField() != "" {
|
|
t.Errorf("%s read as class %q, leaf %v (%v, unknown %q), want leaf %v", raw, m.Class, m.Leaf(), err, m.UnknownField(), leaf)
|
|
}
|
|
}
|
|
}
|