Skip to content

Commit

Permalink
fix: order conditions summary (#20759)
Browse files Browse the repository at this point in the history
Signed-off-by: Matthieu MOREL <[email protected]>
  • Loading branch information
mmorel-35 authored Nov 20, 2024
1 parent 3da5a3d commit 0ca1ddb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cmd/argocd/commands/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"io"
"os"
"reflect"
"slices"
"sort"
"strconv"
"strings"
Expand Down Expand Up @@ -1738,6 +1739,7 @@ func formatConditionsSummary(app argoappv1.Application) string {
}
summary := "<none>"
if len(items) > 0 {
slices.Sort(items)
summary = strings.Join(items, ",")
}
return summary
Expand Down
21 changes: 21 additions & 0 deletions cmd/argocd/commands/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,27 @@ func TestFormatConditionSummary(t *testing.T) {
summary := formatConditionsSummary(app)
require.Equalf(t, "type1(2),type2", summary, "Incorrect summary %q, should be type1(2),type2", summary)
})

t.Run("Conditions are sorted for idempotent summary", func(t *testing.T) {
app := v1alpha1.Application{
Status: v1alpha1.ApplicationStatus{
Conditions: []v1alpha1.ApplicationCondition{
{
Type: "type2",
},
{
Type: "type1",
},
{
Type: "type1",
},
},
},
}

summary := formatConditionsSummary(app)
require.Equalf(t, "type1(2),type2", summary, "Incorrect summary %q, should be type1(2),type2", summary)
})
}

func TestPrintOperationResult(t *testing.T) {
Expand Down

0 comments on commit 0ca1ddb

Please sign in to comment.