Skip to content

Commit d7ef3c1

Browse files
committed
fix: linter issues
1 parent 8429679 commit d7ef3c1

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

collector/nginx.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,14 @@ func (c *NginxCollector) handleScrapeError(ch chan<- prometheus.Metric, err erro
7878
errorMsg := err.Error()
7979
var errorType string
8080

81-
if isNetworkError(errorMsg) {
81+
switch {
82+
case isNetworkError(errorMsg):
8283
c.upMetric.Set(nginxDown)
8384
errorType = "network"
84-
} else if isHTTPError(errorMsg) {
85+
case isHTTPError(errorMsg):
8586
c.upMetric.Set(nginxUp)
8687
errorType = "http"
87-
} else {
88+
default:
8889
c.upMetric.Set(nginxUp)
8990
errorType = "parse"
9091
}

collector/nginx_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import (
88
)
99

1010
func TestIsNetworkError(t *testing.T) {
11+
t.Parallel()
12+
1113
tests := []struct {
1214
name string
1315
errorMsg string
@@ -37,6 +39,7 @@ func TestIsNetworkError(t *testing.T) {
3739

3840
for _, tt := range tests {
3941
t.Run(tt.name, func(t *testing.T) {
42+
t.Parallel()
4043
if got := isNetworkError(tt.errorMsg); got != tt.want {
4144
t.Errorf("isNetworkError() = %v, want %v", got, tt.want)
4245
}
@@ -45,6 +48,8 @@ func TestIsNetworkError(t *testing.T) {
4548
}
4649

4750
func TestIsHTTPError(t *testing.T) {
51+
t.Parallel()
52+
4853
tests := []struct {
4954
name string
5055
errorMsg string
@@ -74,6 +79,7 @@ func TestIsHTTPError(t *testing.T) {
7479

7580
for _, tt := range tests {
7681
t.Run(tt.name, func(t *testing.T) {
82+
t.Parallel()
7783
if got := isHTTPError(tt.errorMsg); got != tt.want {
7884
t.Errorf("isHTTPError() = %v, want %v", got, tt.want)
7985
}
@@ -82,6 +88,8 @@ func TestIsHTTPError(t *testing.T) {
8288
}
8389

8490
func TestNewScrapeSuccessMetric(t *testing.T) {
91+
t.Parallel()
92+
8593
metric := newScrapeSuccessMetric("nginx", map[string]string{"job": "nginx"})
8694

8795
if metric == nil {
@@ -95,6 +103,8 @@ func TestNewScrapeSuccessMetric(t *testing.T) {
95103
}
96104

97105
func TestNewScrapeDurationMetric(t *testing.T) {
106+
t.Parallel()
107+
98108
metric := newScrapeDurationMetric("nginx", map[string]string{"job": "nginx"})
99109

100110
if metric == nil {
@@ -108,10 +118,13 @@ func TestNewScrapeDurationMetric(t *testing.T) {
108118
}
109119

110120
func TestNewScrapeErrorsTotalMetric(t *testing.T) {
121+
t.Parallel()
122+
111123
metric := newScrapeErrorsTotalMetric("nginx", map[string]string{"job": "nginx"})
112124

113125
if metric == nil {
114126
t.Error("newScrapeErrorsTotalMetric() returned nil")
127+
return
115128
}
116129

117130
ch := make(chan *prometheus.Desc, 10)

0 commit comments

Comments
 (0)