@@ -2,6 +2,7 @@ package jmx
22
33import (
44 "bufio"
5+ "bytes"
56 "context"
67 "flag"
78 "fmt"
@@ -10,6 +11,7 @@ import (
1011 "testing"
1112 "time"
1213
14+ "github.com/newrelic/infra-integrations-sdk/v4/log"
1315 "github.com/stretchr/testify/assert"
1416 "github.com/stretchr/testify/require"
1517)
@@ -179,17 +181,25 @@ func openWaitWithSSL(hostname, port, username, password, keyStore, keyStorePassw
179181}
180182
181183func Test_receiveResult_warningsDoNotBreakResultReception (t * testing.T ) {
184+
185+ var buf bytes.Buffer
186+ log .SetOutput (& buf )
187+
182188 _ , cancelFn := context .WithCancel (context .Background ())
183189
184190 resultCh := make (chan []byte , 1 )
185191 queryErrCh := make (chan error )
186192 outTimeout := time .Duration (timeoutMillis ) * time .Millisecond
193+ warningMessage := fmt .Sprint ("WARNING foo bar" )
194+ cmdWarnC <- warningMessage
187195
188- _ , _ = receiveResult ( resultCh , queryErrCh , cancelFn , "empty" , outTimeout )
196+ resultCh <- [] byte ( "{ \" foo \" :1}" )
189197
190- cmdErrC <- fmt .Errorf ("WARNING foo bar" )
191- assert .Equal (t , <- cmdErrC , fmt .Errorf ("WARNING foo bar" ))
198+ result , err := receiveResult (resultCh , queryErrCh , cancelFn , "foo" , outTimeout )
192199
193- resultCh <- []byte ("{foo}" )
194- assert .Equal (t , string (<- resultCh ), "{foo}" )
200+ assert .NoError (t , err )
201+ assert .Equal (t , map [string ]interface {}{
202+ "foo" : 1. ,
203+ }, result )
204+ assert .Equal (t , fmt .Sprintf ("[WARN] %s\n " , warningMessage ), buf .String ())
195205}
0 commit comments