-
-
Notifications
You must be signed in to change notification settings - Fork 630
fix(alerting): Support custom slack title #1079
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Could you please review this pull request? If it suits your application, feel free to merge it into the main codebase or alternatively, write your own version if preferred. |
TwiN
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you revert all indentation changes?
6fcf440 to
c1abfd3
Compare
|
I'm sorry I overlooked the indentation and didn't follow your workflow preference of using tabs instead of spaces. |
TwiN
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks fine, but can you add a test?
|
@mehdiMj-ir fyi it's not my workflow preference, it's what gofmt does. Tbf I care more about consistency than specific preferences |
|
TBH, I'm a sysAdmin, not a programmer 😅 |
|
I am indeed sorry, I am not a programmer. I tried chatGPT but it's not like your code and it have a hard coded url Go test code.func TestAlertProvider_WithCustomTitle(t *testing.T) {
provider := Provider{
Title: "🚨 Custom Title 🚨",
WebhookURL: "https://hooks.slack.com/test-webhook",
}
alert := &alert.Alert{
Description: "Service is DOWN",
}
endpoint := &core.Endpoint{
Name: "my-service",
}
result := &core.Result{
Success: false,
}
body, err := provider.buildRequestBody(alert, endpoint, result)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
if !strings.Contains(body, provider.Title) {
t.Errorf("expected body to contain custom title %q, got: %s", provider.Title, body)
}
}
func TestAlertProvider_DefaultTitleWhenEmpty(t *testing.T) {
provider := Provider{
WebhookURL: "https://hooks.slack.com/test-webhook",
// Title left empty
}
alert := &alert.Alert{
Description: "Service is DOWN",
}
endpoint := &core.Endpoint{
Name: "my-service",
}
result := &core.Result{
Success: false,
}
body, err := provider.buildRequestBody(alert, endpoint, result)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
// Default title should fallback to endpoint name
if !strings.Contains(body, "my-service") {
t.Errorf("expected body to contain default title %q, got: %s", "my-service", body)
}
} |
|
@mehdiMj-ir There's no need to be sorry, don't worry. Re-open your PR, I'll add the tests myself when I have a moment 🙂 |
Summary
Support for custom Slack title via configuration #927
Fixes #927
Checklist
README.md, if applicable.