Skip to content

Commit

Permalink
Merge pull request messagebird#114 from dzyanis/fix-unit-test
Browse files Browse the repository at this point in the history
fixed alert text random order
  • Loading branch information
marcel corso gonzalez committed Mar 23, 2022
2 parents c51ff90 + 03b49ff commit 072afb6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
linter:
./bin/golangci-lint run ./... --timeout=5m
.PHONY: linter

linter.download:
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh
.PHONY: linter.download

test:
env CGO_ENABLED=1 go test -race ./...
.PHONY: test

alltest: linter test
.PHONY: alltest
2 changes: 2 additions & 0 deletions cmd/sachet/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"log"
"net/http"
"sort"
"strings"

"github.com/prometheus/alertmanager/template"
Expand Down Expand Up @@ -42,6 +43,7 @@ func newAlertText(data template.Data) string {
for k, v := range alert.Labels {
tuples = append(tuples, k+"= "+v)
}
sort.Strings(tuples)
return strings.ToUpper(data.Status) + " \n" + strings.Join(tuples, "\n")
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/sachet/handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func Test_newAlertText(t *testing.T) {
exp: " \n",
},
{
name: "alerts labels",
name: "alert labels",
data: template.Data{
Alerts: template.Alerts{
template.Alert{
Expand All @@ -42,7 +42,7 @@ func Test_newAlertText(t *testing.T) {
},
},
},
exp: " \nalertname= a\ninstance= a\nexported_instance= a",
exp: " \nalertname= a\nexported_instance= a\ninstance= a",
},
{
name: "common labels",
Expand Down

0 comments on commit 072afb6

Please sign in to comment.