@@ -66,6 +66,7 @@ func newTestClientWithPresetResponses(codes []int, bodies []string) (*http.Clien
66
66
67
67
return & http.Response {
68
68
StatusCode : code ,
69
+ Request : req ,
69
70
Body : io .NopCloser (bytes .NewBufferString (body )),
70
71
Header : make (http.Header ),
71
72
}
@@ -1316,7 +1317,12 @@ func TestErrorReceived(t *testing.T) {
1316
1317
case <- time .After (5 * time .Second ):
1317
1318
t .Fatal ("Should have received request" )
1318
1319
}
1319
- assert .EqualError (t , err , "HTTP 500 \" Internal Server Error\" " )
1320
+ errMsg := fmt .Sprintf ("HTTP %q %d %q" ,
1321
+ cfg .ClientConfig .Endpoint ,
1322
+ http .StatusInternalServerError ,
1323
+ http .StatusText (http .StatusInternalServerError ),
1324
+ )
1325
+ assert .EqualError (t , err , errMsg )
1320
1326
}
1321
1327
1322
1328
func TestInvalidLogs (t * testing.T ) {
@@ -1394,7 +1400,10 @@ func TestHeartbeatStartupFailed(t *testing.T) {
1394
1400
assert .NoError (t , err )
1395
1401
assert .EqualError (t ,
1396
1402
exporter .Start (context .Background (), componenttest .NewNopHost ()),
1397
- fmt .Sprintf ("%s: heartbeat on startup failed: HTTP 403 \" Forbidden\" " , params .ID .String ()),
1403
+ fmt .Sprintf ("%s: heartbeat on startup failed: HTTP %q 403 \" Forbidden\" " ,
1404
+ params .ID .String (),
1405
+ cfg .ClientConfig .Endpoint ,
1406
+ ),
1398
1407
)
1399
1408
assert .NoError (t , exporter .Shutdown (context .Background ()))
1400
1409
}
@@ -1605,17 +1614,16 @@ func Test_pushLogData_ShouldAddResponseTo400Error(t *testing.T) {
1605
1614
// Sending logs using the client.
1606
1615
err := splunkClient .pushLogData (context .Background (), logs )
1607
1616
require .True (t , consumererror .IsPermanent (err ), "Expecting permanent error" )
1608
- require .ErrorContains (t , err , "HTTP/0.0 400" )
1617
+ require .EqualError (t , err , "Permanent error: HTTP \" http://splunk \" 400 \" Bad Request \" " )
1609
1618
// The returned error should contain the response body responseBody.
1610
- assert .ErrorContains (t , err , responseBody )
1611
1619
1612
1620
// An HTTP client that returns some other status code other than 400 and response body responseBody.
1613
1621
httpClient , _ = newTestClient (500 , responseBody )
1614
1622
splunkClient .hecWorker = & defaultHecWorker {url , httpClient , buildHTTPHeaders (config , component .NewDefaultBuildInfo ()), zap .NewNop ()}
1615
1623
// Sending logs using the client.
1616
1624
err = splunkClient .pushLogData (context .Background (), logs )
1617
1625
require .False (t , consumererror .IsPermanent (err ), "Expecting non-permanent error" )
1618
- require .ErrorContains (t , err , "HTTP 500" )
1626
+ require .EqualError (t , err , "HTTP \" http://splunk \" 500 \" Internal Server Error \" " )
1619
1627
// The returned error should not contain the response body responseBody.
1620
1628
assert .NotContains (t , err .Error (), responseBody )
1621
1629
}
0 commit comments