github.com/webonyx/up@v0.7.4-0.20180808230834-91b94e551323/http/poweredby/poweredby_test.go (about) 1 package poweredby 2 3 import ( 4 "net/http/httptest" 5 "testing" 6 7 "github.com/tj/assert" 8 "github.com/apex/up" 9 10 "github.com/apex/up/config" 11 "github.com/apex/up/http/static" 12 ) 13 14 func TestPoweredby(t *testing.T) { 15 c := &up.Config{ 16 Static: config.Static{ 17 Dir: "testdata", 18 }, 19 } 20 21 h := New("up", static.New(c)) 22 23 res := httptest.NewRecorder() 24 req := httptest.NewRequest("GET", "/", nil) 25 26 h.ServeHTTP(res, req) 27 28 assert.Equal(t, 200, res.Code) 29 assert.Equal(t, "up", res.Header().Get("X-Powered-By")) 30 assert.Equal(t, "text/html; charset=utf-8", res.Header().Get("Content-Type")) 31 assert.Equal(t, "Index HTML\n", res.Body.String()) 32 }