Monorepo for Tangled tangled.org
2

Configure Feed

Select the types of activity you want to include in your feed.

at icy/yovxsu 1.6 kB View raw
1package state 2 3import ( 4 "testing" 5 6 ec "tangled.org/core/eventconsumer" 7 "tangled.org/core/eventconsumer/cursor" 8) 9 10func TestMigrateLegacyCursor_CopiesBareHostToKindKey(t *testing.T) { 11 store := &cursor.MemoryStore{} 12 store.Set("clam.oyster.cafe", 1700000000123456789) 13 14 migrateLegacyCursor(store, ec.NewKnotSource("clam.oyster.cafe")) 15 16 if got := store.Get("knot:clam.oyster.cafe"); got != 1700000000123456789 { 17 t.Fatalf("new key cursor = %d, want legacy value", got) 18 } 19} 20 21func TestMigrateLegacyCursor_DoesNotClobberAdvancedCursor(t *testing.T) { 22 store := &cursor.MemoryStore{} 23 store.Set("knot:whelk.oyster.cafe", 999) 24 store.Set("whelk.oyster.cafe", 100) 25 26 migrateLegacyCursor(store, ec.NewKnotSource("whelk.oyster.cafe")) 27 28 if got := store.Get("knot:whelk.oyster.cafe"); got != 999 { 29 t.Fatalf("new key cursor = %d, want it left untouched at 999", got) 30 } 31} 32 33func TestMigrateLegacyCursor_NoLegacyIsNoOp(t *testing.T) { 34 store := &cursor.MemoryStore{} 35 36 migrateLegacyCursor(store, ec.NewKnotSource("limpet.nel.pet")) 37 38 if got := store.Get("knot:limpet.nel.pet"); got != 0 { 39 t.Fatalf("new key cursor = %d, want 0", got) 40 } 41} 42 43func TestMigrateLegacyCursor_KindsStayNamespaced(t *testing.T) { 44 store := &cursor.MemoryStore{} 45 store.Set("mussel.oyster.cafe", 500) 46 47 migrateLegacyCursor(store, ec.NewKnotSource("mussel.oyster.cafe")) 48 migrateLegacyCursor(store, ec.NewSpindleSource("mussel.oyster.cafe")) 49 50 if got := store.Get("knot:mussel.oyster.cafe"); got != 500 { 51 t.Fatalf("knot cursor = %d, want 500", got) 52 } 53 if got := store.Get("spindle:mussel.oyster.cafe"); got != 500 { 54 t.Fatalf("spindle cursor = %d, want 500", got) 55 } 56}