Skip to content

Commit

Permalink
chore(test): Test flaky test for teams (#2638)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaspoignant authored Nov 8, 2024
1 parent 012ea4c commit 3d3a545
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions notifier/microsoftteamsnotifier/notifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package microsoftteamsnotifier
import (
"fmt"
"os"
"sort"
"strings"

goteamsnotify "github.com/atc0005/go-teams-notify/v2"
Expand Down Expand Up @@ -37,15 +38,35 @@ func (c *Notifier) Notify(diff notifier.DiffCache) error {
func convertToMicrosoftTeamsMessage(diffCache notifier.DiffCache) string {
hostname, _ := os.Hostname()
msgText := fmt.Sprintf("Changes detected in your feature flag file on: **%s**", hostname)
for key := range diffCache.Deleted {

// Deleted
deletedKeys := make([]string, 0, len(diffCache.Deleted))
for k := range diffCache.Deleted {
deletedKeys = append(deletedKeys, k)
}
sort.Strings(deletedKeys)
for _, key := range deletedKeys {
msgText += fmt.Sprintf("\n * ❌ Flag **%s** deleted", key)
}

for key := range diffCache.Added {
// Added
addedKeys := make([]string, 0, len(diffCache.Added))
for k := range diffCache.Added {
addedKeys = append(addedKeys, k)
}
sort.Strings(addedKeys)
for _, key := range addedKeys {
msgText += fmt.Sprintf("\n * 🆕 Flag **%s** created", key)
}

for key, value := range diffCache.Updated {
// Updated
updatedKeys := make([]string, 0, len(diffCache.Updated))
for k := range diffCache.Updated {
updatedKeys = append(updatedKeys, k)
}
sort.Strings(updatedKeys)
for _, key := range updatedKeys {
value := diffCache.Updated[key]
msgText += fmt.Sprintf("\n * ✏️ Flag **%s** updated", key)
changelog, _ := diff.Diff(value.Before, value.After, diff.AllowTypeMismatch(true))
for _, change := range changelog {
Expand Down

0 comments on commit 3d3a545

Please sign in to comment.