Skip to content

Commit

Permalink
Id check tests: stop using Exchange (#1343)
Browse files Browse the repository at this point in the history
Using Exchange doesn't add anything, as it just wraps client.Exchange
with a default client.

Remove them and speed up the tests, goes from 3s to 1s (for the entire
test suite).

Signed-off-by: Miek Gieben <[email protected]>
  • Loading branch information
miekg authored Mar 2, 2022
1 parent 84af068 commit af1ebf5
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,16 +257,14 @@ func TestClientSyncBadID(t *testing.T) {
m := new(Msg)
m.SetQuestion("miek.nl.", TypeSOA)

// Test with client.Exchange, the plain Exchange function is just a wrapper, so
// we don't need to test that separately.
c := &Client{
Timeout: 50 * time.Millisecond,
Timeout: 10 * time.Millisecond,
}
if _, _, err := c.Exchange(m, addrstr); err == nil || !isNetworkTimeout(err) {
t.Errorf("query did not time out")
}
// And now with plain Exchange().
if _, err = Exchange(m, addrstr); err == nil || !isNetworkTimeout(err) {
t.Errorf("query did not time out")
}
}

func TestClientSyncBadThenGoodID(t *testing.T) {
Expand All @@ -290,14 +288,6 @@ func TestClientSyncBadThenGoodID(t *testing.T) {
if r.Id != m.Id {
t.Errorf("failed to get response with expected Id")
}
// And now with plain Exchange().
r, err = Exchange(m, addrstr)
if err != nil {
t.Errorf("failed to exchange: %v", err)
}
if r.Id != m.Id {
t.Errorf("failed to get response with expected Id")
}
}

func TestClientSyncTCPBadID(t *testing.T) {
Expand Down

0 comments on commit af1ebf5

Please sign in to comment.