@@ -406,6 +406,7 @@ func TestResponseCheckOnly(t *testing.T) {
406
406
{
407
407
name : "Valid answer without header" ,
408
408
response : & http.Response {
409
+ StatusCode : http .StatusOK ,
409
410
Body : ioutil .NopCloser (strings .NewReader ("{}" )),
410
411
},
411
412
wantErr : true ,
@@ -421,6 +422,7 @@ func TestResponseCheckOnly(t *testing.T) {
421
422
{
422
423
name : "Valid answer without header and response check" ,
423
424
response : & http.Response {
425
+ StatusCode : http .StatusOK ,
424
426
Body : ioutil .NopCloser (strings .NewReader ("{}" )),
425
427
},
426
428
wantErr : true ,
@@ -438,7 +440,7 @@ func TestResponseCheckOnly(t *testing.T) {
438
440
Body : ioutil .NopCloser (strings .NewReader ("" )),
439
441
},
440
442
requestErr : nil ,
441
- wantErr : true ,
443
+ wantErr : false ,
442
444
},
443
445
{
444
446
name : "Valid request, 404 response" ,
@@ -447,7 +449,7 @@ func TestResponseCheckOnly(t *testing.T) {
447
449
Body : ioutil .NopCloser (strings .NewReader ("" )),
448
450
},
449
451
requestErr : nil ,
450
- wantErr : true ,
452
+ wantErr : false ,
451
453
},
452
454
{
453
455
name : "Valid request, 403 response" ,
@@ -494,14 +496,15 @@ func TestProductCheckError(t *testing.T) {
494
496
w .WriteHeader (http .StatusBadGateway )
495
497
return
496
498
}
499
+
497
500
w .Header ().Set ("X-Elastic-Product" , "Elasticsearch" )
498
501
w .Write ([]byte ("{}" ))
499
502
}))
500
503
defer server .Close ()
501
504
502
505
c , _ := NewClient (Config {Addresses : []string {server .URL }, DisableRetry : true })
503
- if _ , err := c .Cat .Indices (); err = = nil {
504
- t .Fatal ( "expected error" )
506
+ if _ , err := c .Cat .Indices (); err ! = nil {
507
+ t .Fatalf ( "unexpected error: %s" , err )
505
508
}
506
509
if c .productCheckSuccess {
507
510
t .Fatalf ("product check should be invalid, got %v" , c .productCheckSuccess )
0 commit comments