-
-
Save krancour/d9db7348b264282e34faf7154546bbd5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func TestProxyWithHTTP2(t *testing.T) { | |
var proxyHTTP2RequestFnCalled bool | |
h := &httpReverseProxy{ | |
proxyHTTP2RequestFn: func(http.ResponseWriter, *http.Request) { | |
// We hope this function will be called, so keep track of whether it was | |
proxyHTTP2RequestFnCalled = true | |
}, | |
proxyHTTP1xRequestFn: func(http.ResponseWriter, *http.Request) { | |
// If this function was called, there is a flaw in the logic under test | |
assert.Fail(t, "The HTTP/1.x handler should not have been called, but was") | |
}, | |
} | |
// Build an HTTP/2 request (r) to test with | |
h.Proxy(r, nil) | |
assert.True(t, proxyHTTP2RequestFnCalled) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment