From af1ebf55eb990c475a1a30b67318ffabd3bb4e4c Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Wed, 2 Mar 2022 13:52:49 +0100 Subject: [PATCH] Id check tests: stop using Exchange (#1343) 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 --- client_test.go | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/client_test.go b/client_test.go index 71c61770..83d5af70 100644 --- a/client_test.go +++ b/client_test.go @@ -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) { @@ -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) {