mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-15 21:06:39 +08:00
fix: correct test file paths and add test file to gin directory
This commit is contained in:
parent
2a89d2c43e
commit
65bcbbebdf
@ -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 := "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)
|
||||||
|
@ -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 := "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 := "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 := "test_file.txt"
|
||||||
|
|
||||||
w := httptest.NewRecorder()
|
w := httptest.NewRecorder()
|
||||||
c, _ := CreateTestContext(w)
|
c, _ := CreateTestContext(w)
|
||||||
|
2
test_file.txt
Normal file
2
test_file.txt
Normal 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.
|
Loading…
x
Reference in New Issue
Block a user