MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / TestCursorRoundTrip

Function TestCursorRoundTrip

internal/httpapi/pagination_test.go:13–37  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

11const testSecret = "0123456789abcdef0123456789abcdef"
12
13func TestCursorRoundTrip(t *testing.T) {
14 type cur struct {
15 After string `json:"after"`
16 Dir string `json:"dir"`
17 }
18 in := cur{After: "msg_123", Dir: "inbound"}
19 enc, err := EncodeCursor(testSecret, in)
20 if err != nil {
21 t.Fatalf("encode: %v", err)
22 }
23 if enc == "" {
24 t.Fatal("expected non-empty cursor")
25 }
26 // The signed cursor is payload + "." + signature.
27 if strings.Count(enc, ".") != 1 {
28 t.Fatalf("expected exactly one '.' separator, got %q", enc)
29 }
30 var out cur
31 if err := DecodeCursor([]string{testSecret}, enc, &out); err != nil {
32 t.Fatalf("decode: %v", err)
33 }
34 if out != in {
35 t.Fatalf("round-trip mismatch: got %+v want %+v", out, in)
36 }
37}
38
39func TestDecodeCursorEmptyIsNoop(t *testing.T) {
40 out := struct{ A string }{A: "untouched"}

Callers

nothing calls this directly

Calls 3

EncodeCursorFunction · 0.85
DecodeCursorFunction · 0.85
CountMethod · 0.80

Tested by

no test coverage detected