(t *testing.T)
| 117 | } |
| 118 | |
| 119 | func 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 | |
| 148 | func TestGet_NotFound(t *testing.T) { |
| 149 | mux := http.NewServeMux() |
nothing calls this directly
no test coverage detected