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

Function TestModifyMessageLabels_AddRoundTrip

internal/identity/labels_test.go:43–72  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

41}
42
43func TestModifyMessageLabels_AddRoundTrip(t *testing.T) {
44 pool := testutil.TestDB(t)
45 store := identity.NewStore(pool)
46 ctx := context.Background()
47
48 msgID, agentID := labelsTestSetup(t, store, "labels-add")
49
50 final, err := store.ModifyMessageLabels(ctx, msgID, agentID, []string{"urgent", "follow-up"}, nil)
51 if err != nil {
52 t.Fatalf("ModifyMessageLabels: %v", err)
53 }
54 want := []string{"follow-up", "urgent"} // sorted ascending by store
55 if !reflect.DeepEqual(final, want) {
56 t.Errorf("returned labels = %v, want %v", final, want)
57 }
58
59 // Re-read via the inbox query and confirm the labels round-trip.
60 msgs, err := store.GetMessagesByAgent(ctx, identity.MessageListFilter{AgentID: agentID, Status: "all", Direction: "all", Limit: 10})
61 if err != nil {
62 t.Fatalf("GetMessagesByAgent: %v", err)
63 }
64 if len(msgs) != 1 {
65 t.Fatalf("len(msgs) = %d, want 1", len(msgs))
66 }
67 got := append([]string(nil), msgs[0].Labels...)
68 sort.Strings(got)
69 if !reflect.DeepEqual(got, want) {
70 t.Errorf("persisted labels = %v, want %v", got, want)
71 }
72}
73
74func TestModifyMessageLabels_RemoveAndOverlap(t *testing.T) {
75 pool := testutil.TestDB(t)

Callers

nothing calls this directly

Calls 5

ModifyMessageLabelsMethod · 0.95
GetMessagesByAgentMethod · 0.95
TestDBFunction · 0.92
NewStoreFunction · 0.92
labelsTestSetupFunction · 0.85

Tested by

no test coverage detected