diff --git a/pkg/handlers/list_files_test.go b/pkg/handlers/list_files_test.go index 85076f8b..b35a8731 100644 --- a/pkg/handlers/list_files_test.go +++ b/pkg/handlers/list_files_test.go @@ -36,7 +36,7 @@ func TestListFilesHandler_ServeHTTP(t *testing.T) { }, nil }, wantStatusCode: http.StatusOK, - wantBody: `[{"path":"file1.txt"},{"path":"file2.txt"}]`, + wantBody: "[{\"path\":\"file1.txt\"},{\"path\":\"file2.txt\"}]\n", }, { name: "successful listing as text", @@ -61,7 +61,7 @@ func TestListFilesHandler_ServeHTTP(t *testing.T) { }, nil }, wantStatusCode: http.StatusOK, - wantBody: `[{"path":"file1.txt"},{"path":"file2.txt"}]`, + wantBody: "[{\"path\":\"file1.txt\"},{\"path\":\"file2.txt\"}]\n", }, { name: "successful listing with filtering", @@ -85,7 +85,7 @@ func TestListFilesHandler_ServeHTTP(t *testing.T) { }, nil }, wantStatusCode: http.StatusOK, - wantBody: `[{"path":"file2.txt"},{"path":"file2.json"}]`, + wantBody: "[{\"path\":\"file2.txt\"},{\"path\":\"file2.json\"}]\n", }, { name: "project not found", @@ -94,7 +94,7 @@ func TestListFilesHandler_ServeHTTP(t *testing.T) { return nil, project.NewProjectNotFoundError(projectId) }, wantStatusCode: http.StatusNotFound, - wantBody: "project 123 not found", + wantBody: "project 123 not found\n", }, { name: "internal server error", @@ -103,7 +103,7 @@ func TestListFilesHandler_ServeHTTP(t *testing.T) { return nil, errors.New("internal error") }, wantStatusCode: http.StatusInternalServerError, - wantBody: "Failed to list files: internal error", + wantBody: "Failed to list files: internal error\n", }, } @@ -128,7 +128,7 @@ func TestListFilesHandler_ServeHTTP(t *testing.T) { router.ServeHTTP(rr, req) assert.Equal(t, tt.wantStatusCode, rr.Code) - assert.Contains(t, rr.Body.String(), tt.wantBody) + assert.Equal(t, tt.wantBody, rr.Body.String()) }) } }