fix: correct test file paths and add test file to gin directory

This commit is contained in:
caplost 2025-07-21 16:17:27 +08:00
parent 2a89d2c43e
commit 65bcbbebdf
3 changed files with 6 additions and 4 deletions

View File

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

View File

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

2
test_file.txt Normal file
View File

@ -0,0 +1,2 @@
This is a test file for Context.File() method testing.
It contains some sample content to verify file serving functionality.