Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions pkg/handlers/list_files_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
},
}

Expand All @@ -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())
})
}
}