Browse Source

fix lint

pull/305/head
Richard van der Hoff 6 years ago
parent
commit
05aaf714d3
  1. 2
      src/github.com/matrix-org/go-neb/services/alertmanager/alertmanager.go
  2. 22
      src/github.com/matrix-org/go-neb/services/alertmanager/alertmanager_test.go

2
src/github.com/matrix-org/go-neb/services/alertmanager/alertmanager.go

@ -11,8 +11,8 @@ import (
"github.com/matrix-org/gomatrix" "github.com/matrix-org/gomatrix"
html "html/template" html "html/template"
"net/http" "net/http"
text "text/template"
"strings" "strings"
text "text/template"
) )
// ServiceType of the Alertmanager service. // ServiceType of the Alertmanager service.

22
src/github.com/matrix-org/go-neb/services/alertmanager/alertmanager_test.go

@ -1,19 +1,19 @@
package alertmanager package alertmanager
import ( import (
"bytes"
"encoding/json"
"fmt"
"github.com/matrix-org/go-neb/database" "github.com/matrix-org/go-neb/database"
"github.com/matrix-org/go-neb/testutils" "github.com/matrix-org/go-neb/testutils"
"github.com/matrix-org/go-neb/types"
"github.com/matrix-org/gomatrix" "github.com/matrix-org/gomatrix"
"net/http"
"strings"
"fmt"
"encoding/json"
"io/ioutil" "io/ioutil"
"bytes"
"testing"
"github.com/matrix-org/go-neb/types"
"net/http"
"net/http/httptest" "net/http/httptest"
"regexp" "regexp"
"strings"
"testing"
) )
func TestNotify(t *testing.T) { func TestNotify(t *testing.T) {
@ -40,7 +40,7 @@ func TestNotify(t *testing.T) {
matrixCli.Client = &http.Client{Transport: matrixTrans} matrixCli.Client = &http.Client{Transport: matrixTrans}
// create the service // create the service
html_template, err := json.Marshal(
htmlTemplate, err := json.Marshal(
`{{range .Alerts}} `{{range .Alerts}}
{{index .Labels "severity" }} : {{- index .Labels "alertname" -}} {{index .Labels "severity" }} : {{- index .Labels "alertname" -}}
<a href="{{ .GeneratorURL }}">source</a> <a href="{{ .GeneratorURL }}">source</a>
@ -53,7 +53,7 @@ func TestNotify(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
text_template, err := json.Marshal(`{{range .Alerts}}{{index .Labels "alertname"}} {{end}}`)
textTemplate, err := json.Marshal(`{{range .Alerts}}{{index .Labels "alertname"}} {{end}}`)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -64,7 +64,7 @@ func TestNotify(t *testing.T) {
"html_template":%s, "html_template":%s,
"msg_type":"m.text" "msg_type":"m.text"
}} }}
}`, text_template, html_template,
}`, textTemplate, htmlTemplate,
) )
srv, err := types.CreateService("id", "alertmanager", "@neb:hs", []byte(config)) srv, err := types.CreateService("id", "alertmanager", "@neb:hs", []byte(config))
@ -124,7 +124,7 @@ func TestNotify(t *testing.T) {
continue continue
} }
matchedSilence += 1
matchedSilence++
m := silenceRegexp.FindStringSubmatch(line) m := silenceRegexp.FindStringSubmatch(line)
if m == nil { if m == nil {
t.Errorf("silence line %s had bad format", line) t.Errorf("silence line %s had bad format", line)

Loading…
Cancel
Save