Skip to content

Commit da9e29d

Browse files
committed
Update client readme example to compile with previous API changes
1 parent b821083 commit da9e29d

File tree

1 file changed

+8
-20
lines changed

1 file changed

+8
-20
lines changed

client/README.md

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,15 @@ import (
9696
"time"
9797

9898
toxiproxy "github.com/Shopify/toxiproxy/v2/client"
99-
"github.com/garyburd/redigo/redis"
99+
"github.com/gomodule/redigo/redis"
100100
)
101101

102102
var toxiClient *toxiproxy.Client
103-
var proxies map[string]*toxiproxy.Proxy
104103

105104
func init() {
106105
var err error
107106
toxiClient = toxiproxy.NewClient("localhost:8474")
108-
proxies, err = toxiClient.Populate([]toxiproxy.Proxy{{
107+
_, err = toxiClient.Populate([]toxiproxy.Proxy{{
109108
Name: "redis",
110109
Listen: "localhost:26379",
111110
Upstream: "localhost:6379",
@@ -119,8 +118,9 @@ func init() {
119118
}
120119

121120
func TestRedisBackendDown(t *testing.T) {
122-
proxies["redis"].Disable()
123-
defer proxies["redis"].Enable()
121+
var proxy, _ = toxiClient.Proxy("redis")
122+
proxy.Disable()
123+
defer proxy.Enable()
124124

125125
// Test that redis is down
126126
_, err := redis.Dial("tcp", ":26379")
@@ -130,10 +130,11 @@ func TestRedisBackendDown(t *testing.T) {
130130
}
131131

132132
func TestRedisBackendSlow(t *testing.T) {
133-
proxies["redis"].AddToxic("", "latency", "", 1, toxiproxy.Attributes{
133+
var proxy, _ = toxiClient.Proxy("redis")
134+
proxy.AddToxic("", "latency", "", 1, toxiproxy.Attributes{
134135
"latency": 1000,
135136
})
136-
defer proxies["redis"].RemoveToxic("latency_downstream")
137+
defer proxy.RemoveToxic("latency_downstream")
137138

138139
// Test that redis is slow
139140
start := time.Now()
@@ -149,17 +150,4 @@ func TestRedisBackendSlow(t *testing.T) {
149150
t.Fatal("Redis command did not take long enough:", time.Since(start))
150151
}
151152
}
152-
153-
func TestEphemeralProxy(t *testing.T) {
154-
proxy, _ := toxiClient.CreateProxy("test", "", "google.com:80")
155-
defer proxy.Delete()
156-
157-
// Test connection through proxy.Listen
158-
resp, err := http.Get("http://" + proxy.Listen)
159-
if err != nil {
160-
t.Fatal(err)
161-
} else if resp.StatusCode != 200 {
162-
t.Fatal("Proxy to google failed:", resp.StatusCode)
163-
}
164-
}
165153
```

0 commit comments

Comments
 (0)