@@ -16,13 +16,14 @@ package v1
16
16
import (
17
17
"context"
18
18
"errors"
19
- "fmt"
19
+
20
20
"io"
21
21
"math"
22
22
"net/http"
23
23
"net/http/httptest"
24
24
"net/url"
25
25
"reflect"
26
+ "strconv"
26
27
"strings"
27
28
"testing"
28
29
"time"
@@ -260,7 +261,7 @@ func TestAPIs(t *testing.T) {
260
261
},
261
262
{
262
263
do : doQuery ("2" , testTime ),
263
- inErr : fmt . Errorf ("some error" ),
264
+ inErr : errors . New ("some error" ),
264
265
265
266
reqMethod : "POST" ,
266
267
reqPath : "/api/v1/query" ,
@@ -336,7 +337,7 @@ func TestAPIs(t *testing.T) {
336
337
End : testTime ,
337
338
Step : 1 * time .Minute ,
338
339
}, WithTimeout (5 * time .Second )),
339
- inErr : fmt . Errorf ("some error" ),
340
+ inErr : errors . New ("some error" ),
340
341
341
342
reqMethod : "POST" ,
342
343
reqPath : "/api/v1/query_range" ,
@@ -361,14 +362,14 @@ func TestAPIs(t *testing.T) {
361
362
362
363
{
363
364
do : doLabelNames (nil , testTime .Add (- 100 * time .Hour ), testTime ),
364
- inErr : fmt . Errorf ("some error" ),
365
+ inErr : errors . New ("some error" ),
365
366
reqMethod : "POST" ,
366
367
reqPath : "/api/v1/labels" ,
367
368
err : errors .New ("some error" ),
368
369
},
369
370
{
370
371
do : doLabelNames (nil , testTime .Add (- 100 * time .Hour ), testTime ),
371
- inErr : fmt . Errorf ("some error" ),
372
+ inErr : errors . New ("some error" ),
372
373
inWarnings : []string {"a" },
373
374
reqMethod : "POST" ,
374
375
reqPath : "/api/v1/labels" ,
@@ -400,14 +401,14 @@ func TestAPIs(t *testing.T) {
400
401
401
402
{
402
403
do : doLabelValues (nil , "mylabel" , testTime .Add (- 100 * time .Hour ), testTime ),
403
- inErr : fmt . Errorf ("some error" ),
404
+ inErr : errors . New ("some error" ),
404
405
reqMethod : "GET" ,
405
406
reqPath : "/api/v1/label/mylabel/values" ,
406
407
err : errors .New ("some error" ),
407
408
},
408
409
{
409
410
do : doLabelValues (nil , "mylabel" , testTime .Add (- 100 * time .Hour ), testTime ),
410
- inErr : fmt . Errorf ("some error" ),
411
+ inErr : errors . New ("some error" ),
411
412
inWarnings : []string {"a" },
412
413
reqMethod : "GET" ,
413
414
reqPath : "/api/v1/label/mylabel/values" ,
@@ -464,15 +465,15 @@ func TestAPIs(t *testing.T) {
464
465
465
466
{
466
467
do : doSeries ("up" , testTime .Add (- time .Minute ), testTime ),
467
- inErr : fmt . Errorf ("some error" ),
468
+ inErr : errors . New ("some error" ),
468
469
reqMethod : "POST" ,
469
470
reqPath : "/api/v1/series" ,
470
471
err : errors .New ("some error" ),
471
472
},
472
473
// Series with error and warning.
473
474
{
474
475
do : doSeries ("up" , testTime .Add (- time .Minute ), testTime ),
475
- inErr : fmt . Errorf ("some error" ),
476
+ inErr : errors . New ("some error" ),
476
477
inWarnings : []string {"a" },
477
478
reqMethod : "POST" ,
478
479
reqPath : "/api/v1/series" ,
@@ -493,7 +494,7 @@ func TestAPIs(t *testing.T) {
493
494
494
495
{
495
496
do : doSnapshot (true ),
496
- inErr : fmt . Errorf ("some error" ),
497
+ inErr : errors . New ("some error" ),
497
498
reqMethod : "POST" ,
498
499
reqPath : "/api/v1/admin/tsdb/snapshot" ,
499
500
err : errors .New ("some error" ),
@@ -507,7 +508,7 @@ func TestAPIs(t *testing.T) {
507
508
508
509
{
509
510
do : doCleanTombstones (),
510
- inErr : fmt . Errorf ("some error" ),
511
+ inErr : errors . New ("some error" ),
511
512
reqMethod : "POST" ,
512
513
reqPath : "/api/v1/admin/tsdb/clean_tombstones" ,
513
514
err : errors .New ("some error" ),
@@ -528,7 +529,7 @@ func TestAPIs(t *testing.T) {
528
529
529
530
{
530
531
do : doDeleteSeries ("up" , testTime .Add (- time .Minute ), testTime ),
531
- inErr : fmt . Errorf ("some error" ),
532
+ inErr : errors . New ("some error" ),
532
533
reqMethod : "POST" ,
533
534
reqPath : "/api/v1/admin/tsdb/delete_series" ,
534
535
err : errors .New ("some error" ),
@@ -550,8 +551,8 @@ func TestAPIs(t *testing.T) {
550
551
do : doConfig (),
551
552
reqMethod : "GET" ,
552
553
reqPath : "/api/v1/status/config" ,
553
- inErr : fmt . Errorf ("some error" ),
554
- err : fmt . Errorf ("some error" ),
554
+ inErr : errors . New ("some error" ),
555
+ err : errors . New ("some error" ),
555
556
},
556
557
557
558
{
@@ -578,16 +579,16 @@ func TestAPIs(t *testing.T) {
578
579
do : doFlags (),
579
580
reqMethod : "GET" ,
580
581
reqPath : "/api/v1/status/flags" ,
581
- inErr : fmt . Errorf ("some error" ),
582
- err : fmt . Errorf ("some error" ),
582
+ inErr : errors . New ("some error" ),
583
+ err : errors . New ("some error" ),
583
584
},
584
585
585
586
{
586
587
do : doBuildinfo (),
587
588
reqMethod : "GET" ,
588
589
reqPath : "/api/v1/status/buildinfo" ,
589
- inErr : fmt . Errorf ("some error" ),
590
- err : fmt . Errorf ("some error" ),
590
+ inErr : errors . New ("some error" ),
591
+ err : errors . New ("some error" ),
591
592
},
592
593
593
594
{
@@ -616,8 +617,8 @@ func TestAPIs(t *testing.T) {
616
617
do : doRuntimeinfo (),
617
618
reqMethod : "GET" ,
618
619
reqPath : "/api/v1/status/runtimeinfo" ,
619
- inErr : fmt . Errorf ("some error" ),
620
- err : fmt . Errorf ("some error" ),
620
+ inErr : errors . New ("some error" ),
621
+ err : errors . New ("some error" ),
621
622
},
622
623
623
624
{
@@ -684,8 +685,8 @@ func TestAPIs(t *testing.T) {
684
685
do : doAlertManagers (),
685
686
reqMethod : "GET" ,
686
687
reqPath : "/api/v1/alertmanagers" ,
687
- inErr : fmt . Errorf ("some error" ),
688
- err : fmt . Errorf ("some error" ),
688
+ inErr : errors . New ("some error" ),
689
+ err : errors . New ("some error" ),
689
690
},
690
691
691
692
{
@@ -891,8 +892,8 @@ func TestAPIs(t *testing.T) {
891
892
do : doRules (),
892
893
reqMethod : "GET" ,
893
894
reqPath : "/api/v1/rules" ,
894
- inErr : fmt . Errorf ("some error" ),
895
- err : fmt . Errorf ("some error" ),
895
+ inErr : errors . New ("some error" ),
896
+ err : errors . New ("some error" ),
896
897
},
897
898
898
899
{
@@ -971,8 +972,8 @@ func TestAPIs(t *testing.T) {
971
972
do : doTargets (),
972
973
reqMethod : "GET" ,
973
974
reqPath : "/api/v1/targets" ,
974
- inErr : fmt . Errorf ("some error" ),
975
- err : fmt . Errorf ("some error" ),
975
+ inErr : errors . New ("some error" ),
976
+ err : errors . New ("some error" ),
976
977
},
977
978
978
979
{
@@ -1005,7 +1006,7 @@ func TestAPIs(t *testing.T) {
1005
1006
1006
1007
{
1007
1008
do : doTargetsMetadata ("{job=\" prometheus\" }" , "go_goroutines" , "1" ),
1008
- inErr : fmt . Errorf ("some error" ),
1009
+ inErr : errors . New ("some error" ),
1009
1010
reqMethod : "GET" ,
1010
1011
reqPath : "/api/v1/targets/metadata" ,
1011
1012
err : errors .New ("some error" ),
@@ -1037,7 +1038,7 @@ func TestAPIs(t *testing.T) {
1037
1038
1038
1039
{
1039
1040
do : doMetadata ("" , "1" ),
1040
- inErr : fmt . Errorf ("some error" ),
1041
+ inErr : errors . New ("some error" ),
1041
1042
reqMethod : "GET" ,
1042
1043
reqPath : "/api/v1/metadata" ,
1043
1044
err : errors .New ("some error" ),
@@ -1047,8 +1048,8 @@ func TestAPIs(t *testing.T) {
1047
1048
do : doTSDB (),
1048
1049
reqMethod : "GET" ,
1049
1050
reqPath : "/api/v1/status/tsdb" ,
1050
- inErr : fmt . Errorf ("some error" ),
1051
- err : fmt . Errorf ("some error" ),
1051
+ inErr : errors . New ("some error" ),
1052
+ err : errors . New ("some error" ),
1052
1053
},
1053
1054
1054
1055
{
@@ -1127,8 +1128,8 @@ func TestAPIs(t *testing.T) {
1127
1128
do : doWalReply (),
1128
1129
reqMethod : "GET" ,
1129
1130
reqPath : "/api/v1/status/walreplay" ,
1130
- inErr : fmt . Errorf ("some error" ),
1131
- err : fmt . Errorf ("some error" ),
1131
+ inErr : errors . New ("some error" ),
1132
+ err : errors . New ("some error" ),
1132
1133
},
1133
1134
1134
1135
{
@@ -1212,7 +1213,7 @@ func TestAPIs(t *testing.T) {
1212
1213
tests = append (tests , queryTests ... )
1213
1214
1214
1215
for i , test := range tests {
1215
- t .Run (fmt . Sprintf ( "%d" , i ), func (t * testing.T ) {
1216
+ t .Run (strconv . Itoa ( i ), func (t * testing.T ) {
1216
1217
tc .curTest = test
1217
1218
1218
1219
res , warnings , err := test .do ()
@@ -1430,7 +1431,7 @@ func TestAPIClientDo(t *testing.T) {
1430
1431
}
1431
1432
1432
1433
for i , test := range tests {
1433
- t .Run (fmt . Sprintf ( "%d" , i ), func (t * testing.T ) {
1434
+ t .Run (strconv . Itoa ( i ), func (t * testing.T ) {
1434
1435
tc .ch <- test
1435
1436
1436
1437
_ , body , warnings , err := client .Do (context .Background (), tc .req )
0 commit comments