Skip to content

Commit

Permalink
Make mock ListClusters a consistent order
Browse files Browse the repository at this point in the history
  • Loading branch information
joshm91 committed Apr 7, 2021
1 parent a086bc4 commit 873a1f7
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"reflect"
"sort"
"strings"
"testing"

Expand All @@ -22,9 +23,15 @@ type mockKafkaClient struct{ clusters map[string]mockCluster }

func (m mockKafkaClient) ListClusters(ctx context.Context, params *kafka.ListClustersInput, optFns ...func(*kafka.Options)) (*kafka.ListClustersOutput, error) {
var clusterInfoList []types.ClusterInfo
for arn, cluster := range m.clusters {
cArn := arn
cCluster := cluster
keys := make([]string, 0)
for k, _ := range m.clusters {
keys = append(keys, k)
}
sort.Strings(keys)

for _, k := range keys {
cArn := k
cCluster := m.clusters[k]
clusterInfoList = append(clusterInfoList, types.ClusterInfo{
ClusterArn: &cArn,
ClusterName: &cCluster.clusterName,
Expand Down

0 comments on commit 873a1f7

Please sign in to comment.