Skip to content

Commit

Permalink
fix resolver_test
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbourgon committed Jun 1, 2015
1 parent 6d2154c commit 03fca99
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions app/resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ func TestResolver(t *testing.T) {
defer func() { tick = oldTick }()
c := make(chan time.Time)
tick = func(_ time.Duration) <-chan time.Time { return c }

oldLookupIP := lookupIP
defer func() { lookupIP = oldLookupIP }()
ips := map[string][]net.IP{}
Expand All @@ -32,24 +33,17 @@ func TestResolver(t *testing.T) {
adds := make(chan string)
add := func(s string) { adds <- s }

r := newStaticResolver([]string{"symbolic.name" + port}, add)

//c <- time.Now() // trigger initial resolve, with no endpoints
//select {
//case <-time.After(time.Millisecond):
//case s := <-adds:
// t.Errorf("got unexpected add: %q", s)
//}
r := newStaticResolver([]string{"symbolic.name" + port, "namewithnoport", ip1 + port, ip2}, add)

assertAdd := func(want string) {
_, _, line, _ := runtime.Caller(1)
select {
case have := <-adds:
if want != have {
_, _, line, _ := runtime.Caller(1)
t.Errorf("line %d: want %q, have %q", line, want, have)
}
case <-time.After(time.Millisecond):
t.Fatal("didn't get add in time")
t.Fatalf("line %d: didn't get add in time", line)
}
}

Expand Down

0 comments on commit 03fca99

Please sign in to comment.