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