github.com/splucs/witchcraft-go-server@v1.7.0/wrouter/wgorillamux/routerimpl_test.go (about) 1 // Copyright (c) 2018 Palantir Technologies. All rights reserved. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package wgorillamux_test 16 17 import ( 18 "net/http" 19 "net/http/httptest" 20 "testing" 21 22 "github.com/palantir/witchcraft-go-server/wrouter/wgorillamux" 23 "github.com/stretchr/testify/assert" 24 "github.com/stretchr/testify/require" 25 ) 26 27 func TestNew(t *testing.T) { 28 handlerCalled := false 29 router := wgorillamux.New(wgorillamux.NotFoundHandler(http.HandlerFunc(func(_ http.ResponseWriter, _ *http.Request) { 30 handlerCalled = true 31 }))) 32 server := httptest.NewServer(router) 33 defer server.Close() 34 35 _, err := http.Get(server.URL + "/hello") 36 require.NoError(t, err) 37 38 assert.True(t, handlerCalled) 39 }