Fix sorting with right index value 24/76024/1
authorKiran Kamineni <kiran.k.kamineni@intel.com>
Sat, 19 Jan 2019 00:54:25 +0000 (16:54 -0800)
committerKiran Kamineni <kiran.k.kamineni@intel.com>
Sat, 19 Jan 2019 00:54:30 +0000 (16:54 -0800)
Fix the less function used in sort.Slice
with the right index.
I am using the same index which obviously will not work.

Issue-ID: MULTICLOUD-439
Change-Id: Ibb78c03d67cf59e3941acc786796d0cc69b4f0aa
Signed-off-by: Kiran Kamineni <kiran.k.kamineni@intel.com>
src/k8splugin/api/defhandler_test.go
src/k8splugin/api/profilehandler_test.go
src/k8splugin/rb/definition_test.go
src/k8splugin/rb/profile_test.go

index 3dbd1aa..fd17f50 100644 (file)
@@ -216,12 +216,12 @@ func TestRBDefListHandler(t *testing.T) {
                                // Since the order of returned slice is not guaranteed
                                // Check both and return error if both don't match
                                sort.Slice(got, func(i, j int) bool {
-                                       return got[i].UUID < got[i].UUID
+                                       return got[i].UUID < got[j].UUID
                                })
                                // Sort both as it is not expected that testCase.expected
                                // is sorted
                                sort.Slice(testCase.expected, func(i, j int) bool {
-                                       return testCase.expected[i].UUID < testCase.expected[i].UUID
+                                       return testCase.expected[i].UUID < testCase.expected[j].UUID
                                })
 
                                if reflect.DeepEqual(testCase.expected, got) == false {
index 8772588..49efd65 100644 (file)
@@ -223,12 +223,12 @@ func TestRBProfileListHandler(t *testing.T) {
                                // Since the order of returned slice is not guaranteed
                                // Check both and return error if both don't match
                                sort.Slice(got, func(i, j int) bool {
-                                       return got[i].UUID < got[i].UUID
+                                       return got[i].UUID < got[j].UUID
                                })
                                // Sort both as it is not expected that testCase.expected
                                // is sorted
                                sort.Slice(testCase.expected, func(i, j int) bool {
-                                       return testCase.expected[i].UUID < testCase.expected[i].UUID
+                                       return testCase.expected[i].UUID < testCase.expected[j].UUID
                                })
 
                                if reflect.DeepEqual(testCase.expected, got) == false {
index 6074f8b..b360313 100644 (file)
@@ -149,12 +149,12 @@ func TestListDefinition(t *testing.T) {
                                // Since the order of returned slice is not guaranteed
                                // Check both and return error if both don't match
                                sort.Slice(got, func(i, j int) bool {
-                                       return got[i].UUID < got[i].UUID
+                                       return got[i].UUID < got[j].UUID
                                })
                                // Sort both as it is not expected that testCase.expected
                                // is sorted
                                sort.Slice(testCase.expected, func(i, j int) bool {
-                                       return testCase.expected[i].UUID < testCase.expected[i].UUID
+                                       return testCase.expected[i].UUID < testCase.expected[j].UUID
                                })
 
                                if reflect.DeepEqual(testCase.expected, got) == false {
index a760830..26b9747 100644 (file)
@@ -150,12 +150,12 @@ func TestListProfiles(t *testing.T) {
                                // Since the order of returned slice is not guaranteed
                                // Check both and return error if both don't match
                                sort.Slice(got, func(i, j int) bool {
-                                       return got[i].UUID < got[i].UUID
+                                       return got[i].UUID < got[j].UUID
                                })
                                // Sort both as it is not expected that testCase.expected
                                // is sorted
                                sort.Slice(testCase.expected, func(i, j int) bool {
-                                       return testCase.expected[i].UUID < testCase.expected[i].UUID
+                                       return testCase.expected[i].UUID < testCase.expected[j].UUID
                                })
 
                                if reflect.DeepEqual(testCase.expected, got) == false {