mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 14:07:14 +00:00
sort jsonpath_test results
This commit is contained in:
parent
2e2def36a9
commit
9ccceac5e8
@ -20,6 +20,9 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"reflect"
|
||||||
|
"sort"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -43,7 +46,12 @@ func testJSONPath(tests []jsonpathTest, t *testing.T) {
|
|||||||
t.Errorf("in %s, execute error %v", test.name, err)
|
t.Errorf("in %s, execute error %v", test.name, err)
|
||||||
}
|
}
|
||||||
out := buf.String()
|
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)
|
t.Errorf(`in %s, expect to get "%s", got "%s"`, test.name, test.expect, out)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user