Skip to content

Commit

Permalink
sort jsonpath_test results
Browse files Browse the repository at this point in the history
  • Loading branch information
daizuozhuo committed Sep 5, 2015
1 parent 2e2def3 commit 9ccceac
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkg/util/jsonpath/jsonpath_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ import (
"bytes"
"encoding/json"
"fmt"
"reflect"
"sort"
"strings"
"testing"
)

Expand All @@ -43,7 +46,12 @@ func testJSONPath(tests []jsonpathTest, t *testing.T) {
t.Errorf("in %s, execute error %v", test.name, err)
}
out := buf.String()
if out != test.expect {
//since map is itereated in random order, we need to sort the results.
sortedOut := strings.Fields(out)
sort.Strings(sortedOut)
sortedExpect := strings.Fields(test.expect)
sort.Strings(sortedExpect)
if !reflect.DeepEqual(sortedOut, sortedExpect) {
t.Errorf(`in %s, expect to get "%s", got "%s"`, test.name, test.expect, out)
}
}
Expand Down

0 comments on commit 9ccceac

Please sign in to comment.