github.com/chenbh/concourse/v6@v6.4.2/atc/wrappa/versioned_handler_test.go (about) 1 package wrappa_test 2 3 import ( 4 "fmt" 5 . "github.com/chenbh/concourse/v6/atc/testhelpers" 6 "net/http" 7 "net/http/httptest" 8 9 "github.com/chenbh/concourse/v6/atc/wrappa" 10 11 . "github.com/onsi/ginkgo" 12 . "github.com/onsi/gomega" 13 ) 14 15 var _ = Describe("VersionedHandler", func() { 16 var ( 17 version string 18 19 server *httptest.Server 20 client *http.Client 21 22 request *http.Request 23 response *http.Response 24 ) 25 26 BeforeEach(func() { 27 version = "1.2.3-test" 28 29 server = httptest.NewServer(wrappa.VersionedHandler{ 30 Version: version, 31 Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 32 fmt.Fprintln(w, "sup") 33 }), 34 }) 35 36 client = &http.Client{} 37 38 var err error 39 request, err = http.NewRequest("GET", server.URL, nil) 40 Expect(err).ToNot(HaveOccurred()) 41 }) 42 43 JustBeforeEach(func() { 44 var err error 45 response, err = client.Do(request) 46 Expect(err).ToNot(HaveOccurred()) 47 }) 48 49 It("sets the X-Concourse-Version header", func() { 50 expectedHeaderEntries := map[string]string{ 51 "X-Concourse-Version": "1.2.3-test", 52 } 53 Expect(response).Should(IncludeHeaderEntries(expectedHeaderEntries)) 54 }) 55 })