Skip to content

Commit

Permalink
Merge pull request #24 from rabingaire/utils-test
Browse files Browse the repository at this point in the history
Fix convertToSlice test fail
  • Loading branch information
pratishshr authored Jul 8, 2020
2 parents 7c0477a + 04fc189 commit 6dcafb5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions util/shell/shell_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package shell
import (
"fmt"
"reflect"
"sort"
"testing"
)

Expand All @@ -22,11 +23,11 @@ func TestConvertToSlice(t *testing.T) {
{
Name: "With many key value",
Input: map[string]string{
"secretkey": "secretvalue",
"secretkey1": "secretvalue",
"secretkey2": "secretvalue",
"secretkey3": "secretvalue",
},
Output: []string{"secretkey=secretvalue", "secretkey2=secretvalue", "secretkey3=secretvalue"},
Output: []string{"secretkey1=secretvalue", "secretkey2=secretvalue", "secretkey3=secretvalue"},
},
{
Name: "With zero key value",
Expand All @@ -38,6 +39,9 @@ func TestConvertToSlice(t *testing.T) {
for _, tt := range tests {
t.Run(tt.Name, func(t *testing.T) {
output := convertToSlice(tt.Input)
// convertToSlice implementation loops over map and go does no specify the
// iteration order so had to sort the output to test it reliably
sort.Strings(output)
if !reflect.DeepEqual(output, tt.Output) {
t.Fatalf("convertToSlice() error:\ngot %v\nwant %v", output, tt.Output)
}
Expand Down

0 comments on commit 6dcafb5

Please sign in to comment.