mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 15:05:27 +00:00
should not sort when comparing sort results
This commit is contained in:
parent
4d6ef25f64
commit
7e3d250da4
@ -266,11 +266,11 @@ func TestSortMergeLists(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, c := range tc.TestCases {
|
for _, c := range tc.TestCases {
|
||||||
original := testObjectToJSONOrFail(t, c.Original, c.Description)
|
got := sortJsonOrFail(t, testObjectToJSONOrFail(t, c.Original), c.Description)
|
||||||
sorted := testObjectToJSONOrFail(t, c.Sorted, c.Description)
|
expected := testObjectToJSONOrFail(t, c.Sorted)
|
||||||
if !reflect.DeepEqual(original, sorted) {
|
if !reflect.DeepEqual(got, expected) {
|
||||||
t.Errorf("error in test case: %s\ncannot sort object:\n%s\nexpected:\n%s\ngot:\n%s\n",
|
t.Errorf("error in test case: %s\ncannot sort object:\n%s\nexpected:\n%s\ngot:\n%s\n",
|
||||||
c.Description, mergepatch.ToYAMLOrError(c.Original), mergepatch.ToYAMLOrError(c.Sorted), jsonToYAMLOrError(original))
|
c.Description, mergepatch.ToYAMLOrError(c.Original), mergepatch.ToYAMLOrError(c.Sorted), jsonToYAMLOrError(got))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2068,10 +2068,10 @@ func twoWayTestCaseToJSONOrFail(t *testing.T, c StrategicMergePatchTestCase) ([]
|
|||||||
if expectedResult == nil {
|
if expectedResult == nil {
|
||||||
expectedResult = c.Modified
|
expectedResult = c.Modified
|
||||||
}
|
}
|
||||||
return testObjectToJSONOrFail(t, c.Original, c.Description),
|
return sortJsonOrFail(t, testObjectToJSONOrFail(t, c.Original), c.Description),
|
||||||
testObjectToJSONOrFail(t, c.TwoWay, c.Description),
|
sortJsonOrFail(t, testObjectToJSONOrFail(t, c.TwoWay), c.Description),
|
||||||
testObjectToJSONOrFail(t, c.Modified, c.Description),
|
sortJsonOrFail(t, testObjectToJSONOrFail(t, c.Modified), c.Description),
|
||||||
testObjectToJSONOrFail(t, expectedResult, c.Description)
|
sortJsonOrFail(t, testObjectToJSONOrFail(t, expectedResult), c.Description)
|
||||||
}
|
}
|
||||||
|
|
||||||
func twoWayRawTestCaseToJSONOrFail(t *testing.T, c StrategicMergePatchRawTestCase) ([]byte, []byte, []byte, []byte) {
|
func twoWayRawTestCaseToJSONOrFail(t *testing.T, c StrategicMergePatchRawTestCase) ([]byte, []byte, []byte, []byte) {
|
||||||
@ -2168,11 +2168,11 @@ func testThreeWayPatchForRawTestCase(t *testing.T, c StrategicMergePatchRawTestC
|
|||||||
}
|
}
|
||||||
|
|
||||||
func threeWayTestCaseToJSONOrFail(t *testing.T, c StrategicMergePatchTestCase) ([]byte, []byte, []byte, []byte, []byte) {
|
func threeWayTestCaseToJSONOrFail(t *testing.T, c StrategicMergePatchTestCase) ([]byte, []byte, []byte, []byte, []byte) {
|
||||||
return testObjectToJSONOrFail(t, c.Original, c.Description),
|
return sortJsonOrFail(t, testObjectToJSONOrFail(t, c.Original), c.Description),
|
||||||
testObjectToJSONOrFail(t, c.Modified, c.Description),
|
sortJsonOrFail(t, testObjectToJSONOrFail(t, c.Modified), c.Description),
|
||||||
testObjectToJSONOrFail(t, c.Current, c.Description),
|
sortJsonOrFail(t, testObjectToJSONOrFail(t, c.Current), c.Description),
|
||||||
testObjectToJSONOrFail(t, c.ThreeWay, c.Description),
|
sortJsonOrFail(t, testObjectToJSONOrFail(t, c.ThreeWay), c.Description),
|
||||||
testObjectToJSONOrFail(t, c.Result, c.Description)
|
sortJsonOrFail(t, testObjectToJSONOrFail(t, c.Result), c.Description)
|
||||||
}
|
}
|
||||||
|
|
||||||
func threeWayRawTestCaseToJSONOrFail(t *testing.T, c StrategicMergePatchRawTestCase) ([]byte, []byte, []byte, []byte, []byte) {
|
func threeWayRawTestCaseToJSONOrFail(t *testing.T, c StrategicMergePatchRawTestCase) ([]byte, []byte, []byte, []byte, []byte) {
|
||||||
@ -2222,7 +2222,7 @@ func testPatchApplication(t *testing.T, original, patch, expected []byte, descri
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testObjectToJSONOrFail(t *testing.T, o map[string]interface{}, description string) []byte {
|
func testObjectToJSONOrFail(t *testing.T, o map[string]interface{}) []byte {
|
||||||
if o == nil {
|
if o == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -2231,7 +2231,13 @@ func testObjectToJSONOrFail(t *testing.T, o map[string]interface{}, description
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
|
return j
|
||||||
|
}
|
||||||
|
|
||||||
|
func sortJsonOrFail(t *testing.T, j []byte, description string) []byte {
|
||||||
|
if j == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
r, err := sortMergeListsByName(j, mergeItem)
|
r, err := sortMergeListsByName(j, mergeItem)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("error: %s\nin test case: %s\ncannot sort object:\n%s\n", err, description, j)
|
t.Errorf("error: %s\nin test case: %s\ncannot sort object:\n%s\n", err, description, j)
|
||||||
|
Loading…
Reference in New Issue
Block a user