Skip to content

Commit

Permalink
refactor: remove zero delays
Browse files Browse the repository at this point in the history
  • Loading branch information
natesales committed Aug 16, 2023
1 parent 0b75a99 commit bc46aff
Showing 1 changed file with 0 additions and 30 deletions.
30 changes: 0 additions & 30 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@ import (
"regexp"
"strings"
"testing"
"time"

"github.com/stretchr/testify/assert"
)

const delay = 0

func TestMainQuery(t *testing.T) {
clearOpts()
var out bytes.Buffer
Expand All @@ -20,7 +17,6 @@ func TestMainQuery(t *testing.T) {
"-v",
"-q", "example.com",
}, &out))
time.Sleep(delay)
assert.Regexp(t, regexp.MustCompile(`example.com. .* TXT "v=spf1 -all"`), out.String())
}

Expand All @@ -30,7 +26,6 @@ func TestMainVersion(t *testing.T) {
assert.Nil(t, driver([]string{
"-V",
}, &out))
time.Sleep(delay)
assert.Contains(t, out.String(), "https://github.com/natesales/q version dev (unknown unknown)")
}

Expand All @@ -54,7 +49,6 @@ func TestMainRawFormat(t *testing.T) {
"-q", "example.com",
"--format=raw",
}, &out))
time.Sleep(delay)
assert.Contains(t, out.String(), "v=spf1 -all")
assert.Contains(t, out.String(), "a.iana-servers.net")
}
Expand All @@ -68,7 +62,6 @@ func TestMainJSONFormat(t *testing.T) {
"-q", "example.com",
"--format=json",
}, &out))
time.Sleep(delay)
assert.Contains(t, out.String(), `"Preference":0,"Mx":"."`)
assert.Contains(t, out.String(), `"Ns":"a.iana-servers.net."`)
assert.Contains(t, out.String(), `"Txt":["v=spf1 -all"]`)
Expand All @@ -83,7 +76,6 @@ func TestMainInvalidOutputFormat(t *testing.T) {
"-q", "example.com",
"--format=invalid",
}, &out)
time.Sleep(delay)
if !(err != nil && strings.Contains(err.Error(), "invalid output format")) {
t.Errorf("invalid output format should throw an error")
}
Expand All @@ -99,7 +91,6 @@ func TestMainParseTypes(t *testing.T) {
"-t", "A",
"-t", "AAAA",
}, &out))
time.Sleep(delay)
assert.Regexp(t, regexp.MustCompile(`example.com. .* A .*`), out.String())
assert.Regexp(t, regexp.MustCompile(`example.com. .* AAAA .*`), out.String())
}
Expand All @@ -112,7 +103,6 @@ func TestMainInvalidTypes(t *testing.T) {
"-q", "example.com",
"-t", "INVALID",
}, &out)
time.Sleep(delay)
if !(err != nil && strings.Contains(err.Error(), "INVALID is not a valid RR type")) {
t.Errorf("expected invalid type error, got %+v", err)
}
Expand All @@ -127,7 +117,6 @@ func TestMainInvalidODoHUpstream(t *testing.T) {
"-s", "tls://odoh.cloudflare-dns.com",
"--odoh-proxy", "https://odoh.crypto.sx",
}, &out)
time.Sleep(delay)
assert.NotNil(t, err)
assert.Contains(t, err.Error(), "ODoH target must use HTTPS")
}
Expand All @@ -142,7 +131,6 @@ func TestMainInvalidODoHProxy(t *testing.T) {
"-s", "https://odoh.cloudflare-dns.com",
"--odoh-proxy", "tls://odoh1.surfdomeinen.nl",
}, &out)
time.Sleep(delay)
assert.NotNil(t, err)
assert.Contains(t, err.Error(), "ODoH proxy must use HTTPS")
}
Expand All @@ -156,7 +144,6 @@ func TestMainReverseQuery(t *testing.T) {
"-x",
"-q", "1.1.1.1",
}, &out))
time.Sleep(delay)
assert.Regexp(t, regexp.MustCompile(`1.1.1.1.in-addr.arpa. .* PTR one.one.one.one`), out.String())
}

Expand All @@ -169,7 +156,6 @@ func TestMainInferredQname(t *testing.T) {
"example.com",
"A",
}, &out))
time.Sleep(delay)
assert.Regexp(t, regexp.MustCompile(`example.com. .* A .*`), out.String())
}

Expand All @@ -182,7 +168,6 @@ func TestMainInferredServer(t *testing.T) {
"@8.8.8.8",
"-t", "A",
}, &out))
time.Sleep(delay)
assert.Regexp(t, regexp.MustCompile(`example.com. .* A .*`), out.String())
}

Expand Down Expand Up @@ -237,7 +222,6 @@ func TestMainPad(t *testing.T) {
"--pad",
"--format=json",
}, &out))
time.Sleep(delay)
assert.Contains(t, out.String(), `"Truncated":false`)
}

Expand All @@ -251,7 +235,6 @@ func TestMainChaosClass(t *testing.T) {
"TXT",
"@9.9.9.9",
}, &out))
time.Sleep(delay)
assert.Regexp(t, regexp.MustCompile(`id.server. .* TXT ".*.pch.net"`), out.String())
}

Expand All @@ -271,7 +254,6 @@ func TestMainTCPQuery(t *testing.T) {
"-q", "example.com",
"@tcp://1.1.1.1",
}, &out))
time.Sleep(delay)
assert.Regexp(t, regexp.MustCompile(`example.com. .* A .*`), out.String())
}

Expand All @@ -284,7 +266,6 @@ func TestMainTLSQuery(t *testing.T) {
"-t", "A",
"@tls://1.1.1.1",
}, &out))
time.Sleep(delay)
assert.Regexp(t, regexp.MustCompile(`example.com. .* A .*`), out.String())
}

Expand All @@ -297,7 +278,6 @@ func TestMainHTTPSQuery(t *testing.T) {
"-t", "A",
"@https://dns.quad9.net",
}, &out))
time.Sleep(delay)
assert.Regexp(t, regexp.MustCompile(`example.com. .* A .*`), out.String())
}

Expand All @@ -310,7 +290,6 @@ func TestMainQUICQuery(t *testing.T) {
"-t", "A",
"@quic://dns.adguard.com",
}, &out))
time.Sleep(delay)
assert.Regexp(t, regexp.MustCompile(`example.com. .* A .*`), out.String())
}

Expand All @@ -323,7 +302,6 @@ func TestMainInvalidServerURL(t *testing.T) {
"@bad::server::url",
"--format=json",
}, &out))
time.Sleep(delay)
assert.NotRegexp(t, regexp.MustCompile(`example.com. .* A .*`), out.String())
}

Expand All @@ -336,7 +314,6 @@ func TestMainInvalidTransportScheme(t *testing.T) {
"@invalid://example.com",
"--format=json",
}, &out))
time.Sleep(delay)
assert.NotRegexp(t, regexp.MustCompile(`example.com. .* A .*`), out.String())
}

Expand All @@ -351,7 +328,6 @@ func TestMainTLS12(t *testing.T) {
"@tls://dns.quad9.net",
"-t", "A",
}, &out))
time.Sleep(delay)
assert.Regexp(t, regexp.MustCompile(`example.com. .* A .*`), out.String())
}

Expand All @@ -363,7 +339,6 @@ func TestMainNSID(t *testing.T) {
"@tls://dns.quad9.net",
"+nsid",
}, &out))
time.Sleep(delay)
assert.Regexp(t, regexp.MustCompile(`.*.pch.net.*`), out.String())
}

Expand All @@ -377,7 +352,6 @@ func TestMainECSv4(t *testing.T) {
"query.script.packetframe.com",
"--subnet", "192.0.2.0/24",
}, &out))
time.Sleep(delay)
assert.Contains(t, out.String(), `'subnet':'192.0.2.0/24/0'`)
}

Expand All @@ -391,7 +365,6 @@ func TestMainECSv6(t *testing.T) {
"query.script.packetframe.com",
"--subnet", "2001:db8::/48",
}, &out))
time.Sleep(delay)
assert.Contains(t, out.String(), `'subnet':'[2001:db8::]/48/0'`)
}

Expand All @@ -404,7 +377,6 @@ func TestMainHTTPUserAgent(t *testing.T) {
"--http-user-agent", "Example/1.0",
"-t", "NS",
}, &out))
time.Sleep(delay)
assert.Regexp(t, regexp.MustCompile(`. .* NS a.root-servers.net.`), out.String())
}

Expand Down Expand Up @@ -497,7 +469,6 @@ func TestMainRecAXFR(t *testing.T) {
"+recaxfr",
"@nsztm1.digi.ninja", "zonetransfer.me",
}, &out))
time.Sleep(delay)
assert.Contains(t, out.String(), `AXFR zonetransfer.me.`)
assert.Contains(t, out.String(), `AXFR internal.zonetransfer.me.`)
}
Expand All @@ -511,7 +482,6 @@ func TestMainShowAll(t *testing.T) {
"example.com",
"A",
}, &out))
time.Sleep(delay)
assert.Contains(t, out.String(), "example.com.")
assert.Contains(t, out.String(), "Question:")
assert.Contains(t, out.String(), "Answer:")
Expand Down

0 comments on commit bc46aff

Please sign in to comment.