MCPcopy
hub / github.com/vulcand/vulcand / TestTwoHosts

Method TestTwoHosts

proxy/mux/mux_test.go:129–151  ·  view source on GitHub ↗

Test case when you have two hosts on the same socket

(c *C)

Source from the content-addressed store, hash-verified

127
128// Test case when you have two hosts on the same socket
129func (s *ServerSuite) TestTwoHosts(c *C) {
130 e := testutils.NewResponder("Hi, I'm endpoint 1")
131 defer e.Close()
132
133 e2 := testutils.NewResponder("Hi, I'm endpoint 2")
134 defer e2.Close()
135
136 c.Assert(s.mux.Start(), IsNil)
137
138 b := MakeBatch(Batch{Addr: "localhost:41000", Route: `Host("localhost") && Path("/")`, URL: e.URL})
139 b2 := MakeBatch(Batch{Addr: "localhost:41000", Route: `Host("otherhost") && Path("/")`, URL: e2.URL})
140
141 c.Assert(s.mux.UpsertServer(b.BK, b.S), IsNil)
142 c.Assert(s.mux.UpsertServer(b2.BK, b2.S), IsNil)
143
144 c.Assert(s.mux.UpsertFrontend(b.F), IsNil)
145 c.Assert(s.mux.UpsertFrontend(b2.F), IsNil)
146
147 c.Assert(s.mux.UpsertListener(b.L), IsNil)
148
149 c.Assert(GETResponse(c, b.FrontendURL("/"), testutils.Host("localhost")), Equals, "Hi, I'm endpoint 1")
150 c.Assert(GETResponse(c, b.FrontendURL("/"), testutils.Host("otherhost")), Equals, "Hi, I'm endpoint 2")
151}
152
153func (s *ServerSuite) TestListenerCRUD(c *C) {
154 e := testutils.NewResponder("Hi, I'm endpoint")

Callers

nothing calls this directly

Calls 8

MakeBatchFunction · 0.85
FrontendURLMethod · 0.80
GETResponseFunction · 0.70
CloseMethod · 0.65
StartMethod · 0.65
UpsertServerMethod · 0.65
UpsertFrontendMethod · 0.65
UpsertListenerMethod · 0.65

Tested by

no test coverage detected