MCPcopy Create free account
hub / github.com/daodst/chat / TestGetAuthChainSingle

Function TestGetAuthChainSingle

roomserver/internal/query/query_test.go:94–124  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

92}
93
94func TestGetAuthChainSingle(t *testing.T) {
95 db := createEventDB()
96
97 err := db.addFakeEvents(map[string][]string{
98 "a": {},
99 "b": {"a"},
100 "c": {"a", "b"},
101 "d": {"b", "c"},
102 "e": {"a", "d"},
103 })
104
105 if err != nil {
106 t.Fatalf("Failed to add events to db: %v", err)
107 }
108
109 result, err := GetAuthChain(context.TODO(), db.EventsFromIDs, []string{"e"})
110 if err != nil {
111 t.Fatalf("getAuthChain failed: %v", err)
112 }
113
114 var returnedIDs []string
115 for _, event := range result {
116 returnedIDs = append(returnedIDs, event.EventID())
117 }
118
119 expectedIDs := []string{"a", "b", "c", "d", "e"}
120
121 if !test.UnsortedStringSliceEqual(expectedIDs, returnedIDs) {
122 t.Fatalf("returnedIDs got '%v', expected '%v'", returnedIDs, expectedIDs)
123 }
124}
125
126func TestGetAuthChainMultiple(t *testing.T) {
127 db := createEventDB()

Callers

nothing calls this directly

Calls 3

createEventDBFunction · 0.85
GetAuthChainFunction · 0.85
addFakeEventsMethod · 0.80

Tested by

no test coverage detected