mirror of
https://github.com/gofiber/fiber.git
synced 2025-02-23 10:03:45 +00:00
commit
c9664609ee
14
.github/index.html
vendored
Normal file
14
.github/index.html
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Test file</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
Hello, World!
|
||||
</body>
|
||||
|
||||
</html>
|
17
app_test.go
17
app_test.go
@ -8,6 +8,7 @@ import (
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@ -204,6 +205,22 @@ func Test_App_Shutdown(t *testing.T) {
|
||||
}
|
||||
|
||||
// go test -run Test_App_Static
|
||||
func Test_App_Static_Index(t *testing.T) {
|
||||
app := New()
|
||||
|
||||
app.Static("/", "./.github")
|
||||
|
||||
req := httptest.NewRequest("GET", "/", nil)
|
||||
resp, err := app.Test(req)
|
||||
utils.AssertEqual(t, nil, err, "app.Test(req)")
|
||||
utils.AssertEqual(t, 200, resp.StatusCode, "Status code")
|
||||
utils.AssertEqual(t, false, resp.Header.Get("Content-Length") == "")
|
||||
utils.AssertEqual(t, "text/html; charset=utf-8", resp.Header.Get("Content-Type"))
|
||||
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
utils.AssertEqual(t, nil, err)
|
||||
utils.AssertEqual(t, true, strings.Contains(string(body), "Hello, World!"))
|
||||
}
|
||||
func Test_App_Static_Group(t *testing.T) {
|
||||
app := New()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user