|
4 | 4 | "context"
|
5 | 5 | "encoding/json"
|
6 | 6 | "fmt"
|
7 |
| - "strconv" |
| 7 | + "sort" |
8 | 8 | "strings"
|
9 | 9 | "testing"
|
10 | 10 | "time"
|
@@ -36,11 +36,6 @@ func SkipTestIfLocal(t *testing.T, msg string, f func(t *testing.T)) {
|
36 | 36 | t.Run(msg, f)
|
37 | 37 | }
|
38 | 38 |
|
39 |
| -func strPointer(n float32) *string { |
40 |
| - s := strconv.FormatFloat(float64(n), 'f', -1, 64) |
41 |
| - return &s |
42 |
| -} |
43 |
| - |
44 | 39 | // StatefulSetBecomesReady ensures that the underlying stateful set
|
45 | 40 | // reaches the running state.
|
46 | 41 | func StatefulSetBecomesReady(ctx context.Context, mdb *mdbv1.MongoDBCommunity, opts ...wait.Configuration) func(t *testing.T) {
|
@@ -435,10 +430,13 @@ func AutomationConfigHasVoteTagPriorityConfigured(ctx context.Context, mdb *mdbv
|
435 | 430 |
|
436 | 431 | return func(t *testing.T) {
|
437 | 432 | currentAc := getAutomationConfig(ctx, t, mdb)
|
438 |
| - rsMemebers := currentAc.ReplicaSets |
| 433 | + rsMembers := currentAc.ReplicaSets |
| 434 | + sort.Slice(rsMembers[0].Members, func(i, j int) bool { |
| 435 | + return rsMembers[0].Members[i].Id < rsMembers[0].Members[j].Id |
| 436 | + }) |
439 | 437 |
|
440 |
| - for _, m := range rsMemebers[0].Members { |
441 |
| - acMemberOptions = append(acMemberOptions, automationconfig.MemberOptions{Votes: m.Votes, Priority: strPointer(m.Priority), Tags: m.Tags}) |
| 438 | + for _, m := range rsMembers[0].Members { |
| 439 | + acMemberOptions = append(acMemberOptions, automationconfig.MemberOptions{Votes: m.Votes, Priority: floatPtrTostringPtr(m.Priority), Tags: m.Tags}) |
442 | 440 | }
|
443 | 441 | assert.ElementsMatch(t, memberOptions, acMemberOptions)
|
444 | 442 | }
|
@@ -825,3 +823,11 @@ func AddUserToMongoDBCommunity(ctx context.Context, mdb *mdbv1.MongoDBCommunity,
|
825 | 823 | }
|
826 | 824 | }
|
827 | 825 | }
|
| 826 | + |
| 827 | +func floatPtrTostringPtr(floatPtr *float32) *string { |
| 828 | + if floatPtr != nil { |
| 829 | + stringValue := fmt.Sprintf("%.1f", *floatPtr) |
| 830 | + return &stringValue |
| 831 | + } |
| 832 | + return nil |
| 833 | +} |
0 commit comments