fix: update test file paths to use testdata directory

This commit is contained in:
caplost 2025-07-22 15:47:25 +08:00
parent 55ceb53bd4
commit 690ecda6e6
2 changed files with 4 additions and 4 deletions

View File

@ -11,7 +11,7 @@ import (
// TestContextFileSimple tests the Context.File() method with a simple case // TestContextFileSimple tests the Context.File() method with a simple case
func TestContextFileSimple(t *testing.T) { func TestContextFileSimple(t *testing.T) {
// Test serving an existing file // Test serving an existing file
testFile := "test_file.txt" testFile := "testdata/test_file.txt"
w := httptest.NewRecorder() w := httptest.NewRecorder()
c, _ := CreateTestContext(w) c, _ := CreateTestContext(w)
c.Request = httptest.NewRequest(http.MethodGet, "/test", nil) c.Request = httptest.NewRequest(http.MethodGet, "/test", nil)

View File

@ -80,7 +80,7 @@ func TestContextFile(t *testing.T) {
// Test serving an existing file // Test serving an existing file
t.Run("serve existing file", func(t *testing.T) { t.Run("serve existing file", func(t *testing.T) {
// Create a temporary test file // Create a temporary test file
testFile := "test_file.txt" testFile := "testdata/test_file.txt"
w := httptest.NewRecorder() w := httptest.NewRecorder()
c, _ := CreateTestContext(w) c, _ := CreateTestContext(w)
@ -118,7 +118,7 @@ func TestContextFile(t *testing.T) {
// Test with HEAD request // Test with HEAD request
t.Run("HEAD request", func(t *testing.T) { t.Run("HEAD request", func(t *testing.T) {
testFile := "test_file.txt" testFile := "testdata/test_file.txt"
w := httptest.NewRecorder() w := httptest.NewRecorder()
c, _ := CreateTestContext(w) c, _ := CreateTestContext(w)
@ -133,7 +133,7 @@ func TestContextFile(t *testing.T) {
// Test with Range request // Test with Range request
t.Run("Range request", func(t *testing.T) { t.Run("Range request", func(t *testing.T) {
testFile := "test_file.txt" testFile := "testdata/test_file.txt"
w := httptest.NewRecorder() w := httptest.NewRecorder()
c, _ := CreateTestContext(w) c, _ := CreateTestContext(w)