mirror of
https://github.com/gofiber/fiber.git
synced 2025-02-22 09:12:59 +00:00
💉 test: using sendfile method
This commit is contained in:
parent
c78a5013c0
commit
8ad1d16f3a
@ -161,3 +161,29 @@ func Test_FileSystem_NoRoot(t *testing.T) {
|
||||
app.Use(New())
|
||||
_, _ = app.Test(httptest.NewRequest(fiber.MethodGet, "/", nil))
|
||||
}
|
||||
|
||||
func Test_FileSystem_UsingParam(t *testing.T) {
|
||||
app := fiber.New()
|
||||
|
||||
app.Use("/:path", func(c *fiber.Ctx) error {
|
||||
return SendFile(c, http.Dir("../../.github/testdata/fs"), c.Params("path")+".html")
|
||||
})
|
||||
|
||||
req, _ := http.NewRequest(fiber.MethodHead, "/index", nil)
|
||||
resp, err := app.Test(req)
|
||||
utils.AssertEqual(t, nil, err)
|
||||
utils.AssertEqual(t, 200, resp.StatusCode)
|
||||
}
|
||||
|
||||
func Test_FileSystem_UsingParam_NonFile(t *testing.T) {
|
||||
app := fiber.New()
|
||||
|
||||
app.Use("/:path", func(c *fiber.Ctx) error {
|
||||
return SendFile(c, http.Dir("../../.github/testdata/fs"), c.Params("path")+".html")
|
||||
})
|
||||
|
||||
req, _ := http.NewRequest(fiber.MethodHead, "/template", nil)
|
||||
resp, err := app.Test(req)
|
||||
utils.AssertEqual(t, nil, err)
|
||||
utils.AssertEqual(t, 404, resp.StatusCode)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user