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

Function TestCreate_SessionNameInRequest

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

Source from the content-addressed store, hash-verified

59}
60
61func TestCreate_SessionNameInRequest(t *testing.T) {
62 var gotBody map[string]any
63 mux := http.NewServeMux()
64 mux.HandleFunc("/api/sessions", func(w http.ResponseWriter, r *http.Request) {
65 json.NewDecoder(r.Body).Decode(&gotBody)
66 w.Header().Set("Content-Type", "application/json")
67 w.Write(mustJSON(t, map[string]any{"data": map[string]any{"id": "s", "user_id": "u"}}))
68 })
69
70 svc := newService(t, mux)
71 svc.Create(context.Background(), &adksession.CreateRequest{
72 AppName: "app",
73 UserID: "u",
74 State: map[string]any{"session_name": "My Session"},
75 })
76
77 if gotBody["name"] != "My Session" {
78 t.Errorf("name in request body = %v, want 'My Session'", gotBody["name"])
79 }
80}
81
82func TestGet_DeserializesEvents(t *testing.T) {
83 event := map[string]any{

Callers

nothing calls this directly

Calls 4

mustJSONFunction · 0.85
newServiceFunction · 0.85
SetMethod · 0.45
CreateMethod · 0.45

Tested by

no test coverage detected