1
0
mirror of https://github.com/gofiber/fiber.git synced 2025-02-27 15:24:20 +00:00
fiber/response_test.go

28 lines
590 B
Go
Raw Normal View History

2020-02-05 17:37:04 +01:00
package fiber
import (
2020-02-06 03:50:13 +01:00
"net/http"
2020-02-05 17:37:04 +01:00
"testing"
)
func Test_Append(t *testing.T) {
app := New()
2020-02-06 03:50:13 +01:00
app.Get("/test", func(c *Ctx) {
c.Append("X-Test", "hel")
c.Append("X-Test", "lo", "world")
2020-02-05 17:37:04 +01:00
})
2020-02-06 03:50:13 +01:00
req, _ := http.NewRequest("GET", "/test", nil)
2020-02-06 21:34:36 +01:00
resp, err := app.Test(req)
2020-02-06 03:50:13 +01:00
if err != nil {
t.Fatalf(`%s: %s`, t.Name(), err)
2020-02-05 17:37:04 +01:00
}
2020-02-06 21:34:36 +01:00
if resp.StatusCode != 200 {
t.Fatalf(`%s: StatusCode %v`, t.Name(), resp.StatusCode)
}
if resp.Header.Get("X-Test") != "hel, lo, world" {
2020-02-06 03:50:13 +01:00
t.Fatalf(`%s: Expecting %s`, t.Name(), "X-Test: hel, lo, world")
2020-02-05 17:37:04 +01:00
}
}
// TODO: add all functions from response.go