mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-14 17:44:06 -08:00
Fix "go vet" errors.
I ignored all errors of the type "composite literal uses unkeyed fields". Most of them are wrong because of https://github.com/golang/go/issues/9171.
This commit is contained in:
parent
bb0ba8d68f
commit
2ad4987e09
|
@ -113,7 +113,7 @@ func TestQueryCancel(t *testing.T) {
|
|||
t.Fatalf("expected cancellation error for query1 but got none")
|
||||
}
|
||||
if ee := ErrQueryCanceled("test statement execution"); res.Err != ee {
|
||||
t.Fatalf("expected error %q, got %q")
|
||||
t.Fatalf("expected error %q, got %q", ee, res.Err)
|
||||
}
|
||||
|
||||
// Canceling a query before starting it must have no effect.
|
||||
|
@ -198,12 +198,15 @@ func TestRecoverEvaluatorRuntime(t *testing.T) {
|
|||
func TestRecoverEvaluatorError(t *testing.T) {
|
||||
var ev *evaluator
|
||||
var err error
|
||||
defer ev.recover(&err)
|
||||
|
||||
e := fmt.Errorf("custom error")
|
||||
panic(e)
|
||||
|
||||
defer func() {
|
||||
if err.Error() != e.Error() {
|
||||
t.Fatalf("wrong error message: %q, expected %q", err, e)
|
||||
}
|
||||
}()
|
||||
defer ev.recover(&err)
|
||||
|
||||
panic(e)
|
||||
}
|
||||
|
|
|
@ -535,7 +535,6 @@ func (p *parser) expr() Expr {
|
|||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// unaryExpr parses a unary expression.
|
||||
|
|
|
@ -1456,12 +1456,15 @@ func TestRecoverParserRuntime(t *testing.T) {
|
|||
func TestRecoverParserError(t *testing.T) {
|
||||
var p *parser
|
||||
var err error
|
||||
defer p.recover(&err)
|
||||
|
||||
e := fmt.Errorf("custom error")
|
||||
panic(e)
|
||||
|
||||
defer func() {
|
||||
if err.Error() != e.Error() {
|
||||
t.Fatalf("wrong error message: %q, expected %q", err, e)
|
||||
}
|
||||
}()
|
||||
defer p.recover(&err)
|
||||
|
||||
panic(e)
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ func (fd *FileDiscovery) Sources() []string {
|
|||
for _, p := range fd.listFiles() {
|
||||
tgroups, err := readFile(p)
|
||||
if err != nil {
|
||||
log.Errorf("Error reading file %q: ", p, err)
|
||||
log.Errorf("Error reading file %q: %s", p, err)
|
||||
}
|
||||
for _, tg := range tgroups {
|
||||
srcs = append(srcs, tg.Source)
|
||||
|
|
|
@ -66,7 +66,7 @@ func testFileSD(t *testing.T, ext string) {
|
|||
t.Fatalf("Label not parsed")
|
||||
}
|
||||
if tg.String() != fmt.Sprintf("fixtures/_test%s:0", ext) {
|
||||
t.Fatalf("Unexpected target group", tg)
|
||||
t.Fatalf("Unexpected target group %s", tg)
|
||||
}
|
||||
}
|
||||
select {
|
||||
|
|
|
@ -271,7 +271,7 @@ func (kd *Discovery) watchNodes(events chan interface{}, done <-chan struct{}, r
|
|||
return
|
||||
}
|
||||
if res.StatusCode != http.StatusOK {
|
||||
log.Errorf("Failed to watch nodes: %s", res.StatusCode)
|
||||
log.Errorf("Failed to watch nodes: %d", res.StatusCode)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -312,7 +312,7 @@ func (kd *Discovery) watchServices(events chan interface{}, done <-chan struct{}
|
|||
return
|
||||
}
|
||||
if res.StatusCode != http.StatusOK {
|
||||
log.Errorf("Failed to watch services: %s", res.StatusCode)
|
||||
log.Errorf("Failed to watch services: %d", res.StatusCode)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -382,7 +382,7 @@ func (kd *Discovery) addService(service *Service) *config.TargetGroup {
|
|||
return nil
|
||||
}
|
||||
if res.StatusCode != http.StatusOK {
|
||||
log.Errorf("Failed to get service endpoints: %s", res.StatusCode)
|
||||
log.Errorf("Failed to get service endpoints: %d", res.StatusCode)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -453,7 +453,7 @@ func (kd *Discovery) watchServiceEndpoints(events chan interface{}, done <-chan
|
|||
return
|
||||
}
|
||||
if res.StatusCode != http.StatusOK {
|
||||
log.Errorf("Failed to watch service endpoints: %s", res.StatusCode)
|
||||
log.Errorf("Failed to watch service endpoints: %d", res.StatusCode)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -623,7 +623,7 @@ func newTLSConfig(t *testing.T) *tls.Config {
|
|||
tlsConfig.ServerName = "127.0.0.1"
|
||||
cert, err := tls.LoadX509KeyPair("testdata/server.cer", "testdata/server.key")
|
||||
if err != nil {
|
||||
t.Errorf("Unable to use specified server cert (%s) & key (%v): %s", "testdata/server.cer", "testdata/server.key")
|
||||
t.Errorf("Unable to use specified server cert (%s) & key (%v): %s", "testdata/server.cer", "testdata/server.key", err)
|
||||
}
|
||||
tlsConfig.Certificates = []tls.Certificate{cert}
|
||||
tlsConfig.BuildNameToCertificate()
|
||||
|
|
|
@ -178,7 +178,7 @@ func TestTargetManagerChan(t *testing.T) {
|
|||
<-time.After(1 * time.Millisecond)
|
||||
|
||||
if len(targetManager.targets) != len(step.expected) {
|
||||
t.Fatalf("step %d: sources mismatch %v, %v", targetManager.targets, step.expected)
|
||||
t.Fatalf("step %d: sources mismatch %v, %v", i, targetManager.targets, step.expected)
|
||||
}
|
||||
|
||||
for source, actTargets := range targetManager.targets {
|
||||
|
|
|
@ -46,7 +46,7 @@ func (c *TestStorageClient) Store(s model.Samples) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (c TestStorageClient) Name() string {
|
||||
func (c *TestStorageClient) Name() string {
|
||||
return "teststorageclient"
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue