(t *testing.T)
| 1195 | } |
| 1196 | |
| 1197 | func TestHandleWriteFile_Failure_NoPathStoreUpdate(t *testing.T) { |
| 1198 | t.Parallel() |
| 1199 | |
| 1200 | pathStore := agentgit.NewPathStore() |
| 1201 | logger := slogtest.Make(t, nil) |
| 1202 | fs := afero.NewMemMapFs() |
| 1203 | api := agentfiles.NewAPI(logger, fs, pathStore) |
| 1204 | |
| 1205 | chatID := uuid.New() |
| 1206 | |
| 1207 | // Write to a relative path (should fail with 400). |
| 1208 | body := strings.NewReader("hello world") |
| 1209 | req := httptest.NewRequest(http.MethodPost, "/write-file?path=relative/path.txt", body) |
| 1210 | req.Header.Set(workspacesdk.CoderChatIDHeader, chatID.String()) |
| 1211 | |
| 1212 | rr := httptest.NewRecorder() |
| 1213 | r := chi.NewRouter() |
| 1214 | r.Post("/write-file", api.HandleWriteFile) |
| 1215 | agentchat.Middleware(r).ServeHTTP(rr, req) |
| 1216 | |
| 1217 | require.Equal(t, http.StatusBadRequest, rr.Code) |
| 1218 | |
| 1219 | // PathStore should NOT be updated on failure. |
| 1220 | paths := pathStore.GetPaths(chatID) |
| 1221 | require.Empty(t, paths) |
| 1222 | } |
| 1223 | |
| 1224 | func TestHandleEditFiles_ChatHeaders_UpdatesPathStore(t *testing.T) { |
| 1225 | t.Parallel() |
nothing calls this directly
no test coverage detected