unit 302 and integration 34, as at the merge base 45e143f; the buscalls test moves beside busstate's. Builds: design 47 G §419, §626 Claude-Session: https://claude.ai/code/session_01JG73KEq4zoDfM9WtYpcQgZ
39 lines
1.9 KiB
Go
39 lines
1.9 KiB
Go
package catalogue
|
|
|
|
import (
|
|
"slices"
|
|
"testing"
|
|
)
|
|
|
|
// ADR 0666 §16: the bus names of an entry are one rule. A state entry answers its bucket's stream and the stream of
|
|
// its object store; a local name that meets a name the mesh makes is a clash for the judge.
|
|
func subTheBusNamesOfAnEntryAreOneRule(t *testing.T) {
|
|
state := BusStateEntry{Name: "views", Storage: StorageKeyValue, Template: TemplateState}
|
|
rows := []struct {
|
|
name string
|
|
entry BusStateEntry
|
|
streams []string
|
|
}{
|
|
{"a state: its bucket and its object store", state, []string{"KV_m_views", "OBJ_m_views-objects"}},
|
|
{"a key-value that is not a state template: its bucket only", BusStateEntry{Name: "x", Storage: StorageKeyValue}, []string{"KV_m_x"}},
|
|
{"an object store", BusStateEntry{Name: "blobs", Storage: StorageObjectStore, Template: TemplateObjects}, []string{"OBJ_m_blobs"}},
|
|
{"a stream", BusStateEntry{Name: "log", Storage: StorageStream, Template: TemplateLog}, []string{"m_log"}},
|
|
{"a ledger", BusStateEntry{Name: "l", Storage: StorageLedger, Template: TemplateLedger}, []string{"KV_m_l_state", "m_l", "m_l_snapshot"}},
|
|
{"a name that is not one token", BusStateEntry{Name: "a.b", Storage: StorageStream}, nil},
|
|
{"a local name holding the separator", BusStateEntry{Name: "a_b", Storage: StorageStream}, nil},
|
|
}
|
|
for _, r := range rows {
|
|
if got := BusStateStreams("m", r.entry); !slices.Equal(got, r.streams) {
|
|
t.Errorf("%s: streams %v, want %v", r.name, got, r.streams)
|
|
}
|
|
}
|
|
if got := SentObjectsName("m"); got != "m_sent-objects" {
|
|
t.Errorf("sent store %q", got)
|
|
}
|
|
clash := []BusStateEntry{state, {Name: "views-objects", Storage: StorageObjectStore}, {Name: "other-objects", Storage: StorageObjectStore},
|
|
{Name: SentObjectsLocal, Storage: StorageObjectStore}}
|
|
if got := ObjectNameClashes(clash); !slices.Equal(got, []string{"sent-objects", "views-objects"}) {
|
|
t.Errorf("clashes %v", got)
|
|
}
|
|
}
|