github.com/hellofresh/janus@v0.0.0-20230925145208-ce8de8183c67/pkg/middleware/logger_test.go (about) 1 package middleware 2 3 import ( 4 "testing" 5 6 "net/http" 7 8 "github.com/hellofresh/janus/pkg/test" 9 "github.com/stretchr/testify/assert" 10 ) 11 12 func TestSuccessfulLog(t *testing.T) { 13 mw := NewLogger() 14 w, err := test.Record( 15 "GET", 16 "/", 17 map[string]string{ 18 "Content-Type": "application/json", 19 }, 20 mw.Handler(http.HandlerFunc(test.Ping)), 21 ) 22 assert.NoError(t, err) 23 24 assert.Equal(t, http.StatusOK, w.Code) 25 assert.Equal(t, "application/json", w.Header().Get("Content-Type")) 26 }