MCPcopy Index your code
hub / github.com/codegangsta/gin / Test_Proxying

Function Test_Proxying

lib/proxy_test.go:31–58  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

29}
30
31func Test_Proxying(t *testing.T) {
32 builder := NewMockBuilder()
33 runner := NewMockRunner()
34 proxy := gin.NewProxy(builder, runner)
35
36 // create a test server and see if we can proxy a request
37 ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
38 fmt.Fprintln(w, "Hello world")
39 }))
40 defer ts.Close()
41
42 config := &gin.Config{
43 Port: 5678,
44 ProxyTo: ts.URL,
45 }
46
47 err := proxy.Run(config)
48 defer proxy.Close()
49 expect(t, err, nil)
50
51 res, err := http.Get("http://localhost:5678")
52 expect(t, err, nil)
53 expect(t, res == nil, false)
54 greeting, err := ioutil.ReadAll(res.Body)
55 res.Body.Close()
56 expect(t, fmt.Sprintf("%s", greeting), "Hello world\n")
57 expect(t, runner.DidRun, true)
58}
59
60func Test_Proxying_Websocket(t *testing.T) {
61 builder := NewMockBuilder()

Callers

nothing calls this directly

Calls 5

CloseMethod · 0.95
RunMethod · 0.95
NewMockBuilderFunction · 0.85
NewMockRunnerFunction · 0.85
expectFunction · 0.85

Tested by

no test coverage detected