MCPcopy Index your code
hub / github.com/coder/coder / TestAccessLogIncludesChatID

Function TestAccessLogIncludesChatID

agent/agentproc/api_test.go:146–172  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

144}
145
146func TestAccessLogIncludesChatID(t *testing.T) {
147 t.Parallel()
148
149 sink := testutil.NewFakeSink(t)
150 logger := sink.Logger()
151 api := agentproc.NewAPI(logger, agentexec.DefaultExecer, nil, nil, nil)
152 t.Cleanup(func() {
153 _ = api.Close()
154 })
155 handler := tracing.StatusWriterMiddleware(loggermw.Logger(logger, nil)(
156 agentchat.Middleware(api.Routes()),
157 ))
158
159 chatID := uuid.New().String()
160 w := getListWithChatHeader(t, handler, chatID)
161 require.Equal(t, http.StatusOK, w.Code)
162
163 entries := sink.Entries(func(entry slog.SinkEntry) bool {
164 return entry.Message == http.MethodGet
165 })
166 require.Len(t, entries, 1)
167 fields := make(map[string]any, len(entries[0].Fields))
168 for _, field := range entries[0].Fields {
169 fields[field.Name] = field.Value
170 }
171 require.Equal(t, chatID, fields["chat_id"])
172}
173
174// waitForExit polls the output endpoint until the process is
175// no longer running or the context expires.

Callers

nothing calls this directly

Calls 15

LoggerMethod · 0.95
CloseMethod · 0.95
RoutesMethod · 0.95
EntriesMethod · 0.95
NewFakeSinkFunction · 0.92
NewAPIFunction · 0.92
StatusWriterMiddlewareFunction · 0.92
LoggerFunction · 0.92
MiddlewareFunction · 0.92
getListWithChatHeaderFunction · 0.85
CleanupMethod · 0.65
NewMethod · 0.65

Tested by

no test coverage detected