@@ -17,6 +17,7 @@ limitations under the License.
17
17
package impl
18
18
19
19
import (
20
+ "sort"
20
21
"testing"
21
22
22
23
"github.com/stretchr/testify/assert"
@@ -71,13 +72,12 @@ func TestFillPodDevicesAllocatedByKoord(t *testing.T) {
71
72
{
72
73
Name : "test-container" ,
73
74
Devices : []* podresourcesapi.ContainerDevices {
74
- {
75
- ResourceName : string (apiext .ResourceNvidiaGPU ),
76
- DeviceIds : []string {"0" },
77
- },
78
75
{
79
76
ResourceName : string (apiext .ResourceRDMA ),
80
77
DeviceIds : []string {"0000:01:00.2" },
78
+ }, {
79
+ ResourceName : string (apiext .ResourceNvidiaGPU ),
80
+ DeviceIds : []string {"0" },
81
81
},
82
82
},
83
83
},
@@ -147,14 +147,14 @@ func TestFillPodDevicesAllocatedByKoord(t *testing.T) {
147
147
{
148
148
Name : "test-container" ,
149
149
Devices : []* podresourcesapi.ContainerDevices {
150
- {
151
- ResourceName : string (apiext .ResourceNvidiaGPU ),
152
- DeviceIds : []string {"0" },
153
- },
154
150
{
155
151
ResourceName : string (apiext .ResourceRDMA ),
156
152
DeviceIds : []string {"0000:01:00.2" },
157
153
},
154
+ {
155
+ ResourceName : string (apiext .ResourceNvidiaGPU ),
156
+ DeviceIds : []string {"0" },
157
+ },
158
158
},
159
159
},
160
160
},
@@ -296,6 +296,12 @@ func TestFillPodDevicesAllocatedByKoord(t *testing.T) {
296
296
for _ , test := range tests {
297
297
t .Run (test .name , func (t * testing.T ) {
298
298
fillPodDevicesAllocatedByKoord (test .response , test .podList )
299
+ sort .Slice (test .response .PodResources , func (i , j int ) bool {
300
+ return test .response .PodResources [i ].Name < test .response .PodResources [j ].Name
301
+ })
302
+ sort .Slice (test .expectedResult .PodResources , func (i , j int ) bool {
303
+ return test .expectedResult .PodResources [i ].Name < test .expectedResult .PodResources [j ].Name
304
+ })
299
305
assert .Equal (t , test .expectedResult , test .response )
300
306
})
301
307
}
0 commit comments