Fix TestGatheringTimeout test for dns_query plugin (#4842)

This commit is contained in:
kostya-sh 2018-10-11 20:15:17 +01:00 committed by Daniel Nelson
parent 8a03a21de2
commit 502d9ab499
1 changed files with 3 additions and 7 deletions

View File

@ -117,21 +117,17 @@ func TestGatheringTimeout(t *testing.T) {
var acc testutil.Accumulator var acc testutil.Accumulator
dnsConfig.Port = 60054 dnsConfig.Port = 60054
dnsConfig.Timeout = 1 dnsConfig.Timeout = 1
var err error
channel := make(chan error, 1) channel := make(chan error, 1)
go func() { go func() {
channel <- acc.GatherError(dnsConfig.Gather) channel <- acc.GatherError(dnsConfig.Gather)
}() }()
select { select {
case res := <-channel: case err := <-channel:
err = res assert.NoError(t, err)
case <-time.After(time.Second * 2): case <-time.After(time.Second * 2):
err = nil assert.Fail(t, "DNS query did not timeout")
} }
assert.Error(t, err)
assert.Contains(t, err.Error(), "i/o timeout")
} }
func TestSettingDefaultValues(t *testing.T) { func TestSettingDefaultValues(t *testing.T) {