package catalogue import ( "strings" "testing" ) // 1279/AC4 (ADR 0443 ยง4): no module is given a way to ask where its consumer starts. A consumes entry is an event's // name; one that carries a key asking for the stream's history is refused by name, so the safe start is the only one. func TestAConsumesEntryAskingWhereItStartsIsRefused(t *testing.T) { // 1279/AC4 for _, key := range []string{"from", "start", "deliver"} { raw := `{"module":"audit","version":"1","consumes":[{"event":"shop.order.placed","` + key + `":"beginning"}]}` _, err := ParseManifest([]byte(raw)) if err == nil { t.Fatalf("a consumes entry with %q was accepted", key) } if !strings.Contains(err.Error(), `"`+key+`"`) || !strings.Contains(err.Error(), "consumes") { t.Errorf("the refusal for %q does not name the key and the field: %v", key, err) } } if _, err := ParseManifest([]byte(`{"module":"audit","version":"1","consumes":["shop.order.placed"]}`)); err != nil { t.Errorf("a plain consumes entry was refused: %v", err) } }