MCPcopy Create free account
hub / github.com/ContentSquare/chproxy / TestNewReverseProxy

Function TestNewReverseProxy

proxy_test.go:178–200  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

176}
177
178func TestNewReverseProxy(t *testing.T) {
179 proxy := newReverseProxy(&goodCfg.ConnectionPool)
180 if err := proxy.applyConfig(goodCfg); err != nil {
181 t.Fatalf("error while loading config: %s", err)
182 }
183 if len(proxy.clusters) != 1 {
184 t.Fatalf("got %d hosts; expResponse: %d", len(proxy.clusters), 1)
185 }
186 c := proxy.clusters["cluster"]
187 r := c.replicas[0]
188 if len(r.hosts) != 1 {
189 t.Fatalf("got %d hosts; expResponse: %d", len(r.hosts), 1)
190 }
191 if r.hosts[0].Host() != "localhost:8123" {
192 t.Fatalf("got %s host; expResponse: %s", r.hosts[0].Host(), "localhost:8123")
193 }
194 if len(proxy.users) != 1 {
195 t.Fatalf("got %d users; expResponse: %d", len(proxy.users), 1)
196 }
197 if _, ok := proxy.users[defaultUsername]; !ok {
198 t.Fatalf("expected user %q to be present in users", defaultUsername)
199 }
200}
201
202var badCfg = &config.Config{
203 Clusters: []config.Cluster{

Callers

nothing calls this directly

Calls 3

newReverseProxyFunction · 0.85
applyConfigMethod · 0.80
HostMethod · 0.80

Tested by

no test coverage detected