TestContextFileSimple tests the Context.File() method with a simple case
(t *testing.T)
| 10 | |
| 11 | // TestContextFileSimple tests the Context.File() method with a simple case |
| 12 | func TestContextFileSimple(t *testing.T) { |
| 13 | // Test serving an existing file |
| 14 | testFile := "testdata/test_file.txt" |
| 15 | w := httptest.NewRecorder() |
| 16 | c, _ := CreateTestContext(w) |
| 17 | c.Request = httptest.NewRequest(http.MethodGet, "/test", nil) |
| 18 | |
| 19 | c.File(testFile) |
| 20 | |
| 21 | assert.Equal(t, http.StatusOK, w.Code) |
| 22 | assert.Contains(t, w.Body.String(), "This is a test file") |
| 23 | assert.Equal(t, "text/plain; charset=utf-8", w.Header().Get("Content-Type")) |
| 24 | } |
| 25 | |
| 26 | // TestContextFileNotFound tests serving a non-existent file |
| 27 | func TestContextFileNotFound(t *testing.T) { |
nothing calls this directly
no test coverage detected