Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed lookup cache duration #13

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove testify/assert dependency
  • Loading branch information
whs committed Dec 17, 2019
commit 899c5d848c632ef2809e0ce68eb089bee79b8d10
20 changes: 15 additions & 5 deletions dnscache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,25 @@ func TestCacheFailTimeout(t *testing.T) {
Resolver: &mainResolver,
}
_, err := r.LookupHost(context.Background(), "example.notexisting")
assert.NotNil(t, err)
if err == nil {
t.Error("first lookup should have error")
}
_, err = r.LookupHost(context.Background(), "example.notexisting")
assert.NotNil(t, err)
if err == nil {
t.Error("second lookup should have error")
}

assert.Equal(t, 4, resolveCalls)
if resolveCalls != 4 {
t.Errorf("should have 4 resolve calls, got %d", resolveCalls)
}

time.Sleep(10 * time.Millisecond)

_, err = r.LookupHost(context.Background(), "example.notexisting")
assert.NotNil(t, err)
assert.Equal(t, 8, resolveCalls)
if err == nil {
t.Error("post cache timeout lookup should have error")
}
if resolveCalls != 8 {
t.Errorf("should have 8 resolve calls, got %d", resolveCalls)
}
}