MCPcopy
hub / github.com/kagent-dev/kagent / TestGet_EmptyEventsSkipped

Function TestGet_EmptyEventsSkipped

go/adk/pkg/session/session_test.go:119–146  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

117}
118
119func TestGet_EmptyEventsSkipped(t *testing.T) {
120 // Events with no meaningful content should be silently dropped.
121 emptyEvent := map[string]any{} // no author, invocation_id, content, etc.
122 emptyJSON, _ := json.Marshal(emptyEvent)
123
124 mux := http.NewServeMux()
125 mux.HandleFunc("/api/sessions/sess-3", func(w http.ResponseWriter, r *http.Request) {
126 body := map[string]any{
127 "data": map[string]any{
128 "session": map[string]any{"id": "sess-3", "user_id": "u"},
129 "events": []any{map[string]any{"data": json.RawMessage(emptyJSON)}},
130 },
131 }
132 w.Header().Set("Content-Type", "application/json")
133 w.Write(mustJSON(t, body))
134 })
135
136 svc := newService(t, mux)
137 resp, err := svc.Get(context.Background(), &adksession.GetRequest{
138 AppName: "app", UserID: "u", SessionID: "sess-3",
139 })
140 if err != nil {
141 t.Fatalf("Get() error = %v", err)
142 }
143 if n := len(EventsFromSession(resp.Session)); n != 0 {
144 t.Errorf("empty event should be skipped, got %d events", n)
145 }
146}
147
148func TestGet_NotFound(t *testing.T) {
149 mux := http.NewServeMux()

Callers

nothing calls this directly

Calls 5

mustJSONFunction · 0.85
newServiceFunction · 0.85
EventsFromSessionFunction · 0.85
GetMethod · 0.65
SetMethod · 0.45

Tested by

no test coverage detected