Declare httprp server test values as function-scoped constants
Scott Kidder
8 years ago
39 | 39 | } |
40 | 40 | |
41 | 41 | func TestServerHappyPathSingleServerWithServerOptions(t *testing.T) { |
42 | const ( | |
43 | headerKey = "X-TEST-HEADER" | |
44 | headerVal = "go-kit-proxy" | |
45 | ) | |
46 | ||
42 | 47 | originServer := httptest.NewServer( |
43 | 48 | http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
44 | if want, have := "go-kit-proxy", r.Header.Get("X-TEST-HEADER"); want != have { | |
49 | if want, have := headerVal, r.Header.Get(headerKey); want != have { | |
45 | 50 | t.Errorf("want %d, have %d", want, have) |
46 | 51 | } |
47 | 52 | |
55 | 60 | context.Background(), |
56 | 61 | originURL, |
57 | 62 | httptransport.ServerBefore(func(ctx context.Context, r *http.Request) context.Context { |
58 | r.Header.Add("X-TEST-HEADER", "go-kit-proxy") | |
63 | r.Header.Add(headerKey, headerVal) | |
59 | 64 | return ctx |
60 | 65 | }), |
61 | 66 | ) |