remove # from event
parent
10630df394
commit
85d589a570
|
|
@ -38,8 +38,9 @@ func newConfig(ctx context.Context) (Config, error) {
|
|||
|
||||
func newConfigFromEnv(ctx context.Context, getEnv func(string) string) (Config, error) {
|
||||
def := Config{
|
||||
Port: 38080,
|
||||
OllamaModel: "gemma:2b",
|
||||
Port: 38080,
|
||||
OllamaModel: "gemma:2b",
|
||||
AssetPattern: `(dpg|svc|red)-[a-z0-9-]*`,
|
||||
}
|
||||
|
||||
var m map[string]any
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ func TestFillTestdata(t *testing.T) {
|
|||
defer can()
|
||||
|
||||
ram := NewRAM()
|
||||
if err := FillWithTestdata(ctx, ram, `(dpg|svc|svc)-[0-9a-z]*`); err != nil {
|
||||
if err := FillWithTestdata(ctx, ram, renderAssetPattern); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
n := 0
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ func ParseSlack(b []byte, assetPattern string) (Message, error) {
|
|||
Channel: s.Event.Channel,
|
||||
Thread: s.Event.ID,
|
||||
EventName: strings.Split(s.Event.Attachments[0].Title, ": Firing: ")[1],
|
||||
Event: strings.Split(s.Event.Attachments[0].Title, ":")[0],
|
||||
Event: strings.TrimPrefix(strings.Split(s.Event.Attachments[0].Title, ":")[0], "#"),
|
||||
Plaintext: s.Event.Attachments[0].Text,
|
||||
Asset: asset.FindString(s.Event.Attachments[0].Text),
|
||||
Resolved: !strings.HasPrefix(s.Event.Attachments[0].Color, "F"),
|
||||
|
|
|
|||
|
|
@ -7,6 +7,10 @@ import (
|
|||
"testing"
|
||||
)
|
||||
|
||||
var (
|
||||
renderAssetPattern = `(dpg|svc|red)-[a-z0-9-]*[a-z0-9]`
|
||||
)
|
||||
|
||||
func TestParseSlackTestdata(t *testing.T) {
|
||||
cases := map[string]struct {
|
||||
slackMessage slackMessage
|
||||
|
|
@ -74,7 +78,7 @@ func TestParseSlackTestdata(t *testing.T) {
|
|||
Channel: "C06U1DDBBU4",
|
||||
Thread: "1712927439.728409",
|
||||
EventName: "Alertconfig Workflow Failed",
|
||||
Event: "#11071",
|
||||
Event: "11071",
|
||||
Plaintext: "At least one alertconfig run has failed unexpectedly.\nDashboard: <https://grafana.render.com/d/VLZU83YVk?orgId=1>\nPanel: <https://grafana.render.com/d/VLZU83YVk?orgId=1&viewPanel=17>\nSource: <https://grafana.render.com/alerting/grafana/fa7b06b8-b4d8-4979-bce7-5e1c432edd81/view?orgId=1>",
|
||||
Asset: "",
|
||||
},
|
||||
|
|
@ -108,7 +112,7 @@ func TestParseSlackTestdata(t *testing.T) {
|
|||
Channel: "C06U1DDBBU4",
|
||||
Thread: "1712916339.000300",
|
||||
EventName: "Alertconfig Workflow Failed",
|
||||
Event: "#11069",
|
||||
Event: "11069",
|
||||
Plaintext: "At least one alertconfig run has failed unexpectedly.\nDashboard: <https://grafana.render.com/d/VLZU83YVk?orgId=1>\nPanel: <https://grafana.render.com/d/VLZU83YVk?orgId=1&viewPanel=17>\nSource: <https://grafana.render.com/alerting/grafana/fa7b06b8-b4d8-4979-bce7-5e1c432edd81/view?orgId=1>",
|
||||
Asset: "",
|
||||
Resolved: true,
|
||||
|
|
@ -135,7 +139,7 @@ func TestParseSlackTestdata(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("ParseSlack", func(t *testing.T) {
|
||||
got, err := ParseSlack(b, `(red|dpg|svc)-[a-z0-9]*`)
|
||||
got, err := ParseSlack(b, renderAssetPattern)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue