@@ -17,6 +17,7 @@ limitations under the License.
1717package impl
1818
1919import (
20+ "sort"
2021 "testing"
2122
2223 "github.com/stretchr/testify/assert"
@@ -71,13 +72,12 @@ func TestFillPodDevicesAllocatedByKoord(t *testing.T) {
7172 {
7273 Name : "test-container" ,
7374 Devices : []* podresourcesapi.ContainerDevices {
74- {
75- ResourceName : string (apiext .ResourceNvidiaGPU ),
76- DeviceIds : []string {"0" },
77- },
7875 {
7976 ResourceName : string (apiext .ResourceRDMA ),
8077 DeviceIds : []string {"0000:01:00.2" },
78+ }, {
79+ ResourceName : string (apiext .ResourceNvidiaGPU ),
80+ DeviceIds : []string {"0" },
8181 },
8282 },
8383 },
@@ -147,14 +147,14 @@ func TestFillPodDevicesAllocatedByKoord(t *testing.T) {
147147 {
148148 Name : "test-container" ,
149149 Devices : []* podresourcesapi.ContainerDevices {
150- {
151- ResourceName : string (apiext .ResourceNvidiaGPU ),
152- DeviceIds : []string {"0" },
153- },
154150 {
155151 ResourceName : string (apiext .ResourceRDMA ),
156152 DeviceIds : []string {"0000:01:00.2" },
157153 },
154+ {
155+ ResourceName : string (apiext .ResourceNvidiaGPU ),
156+ DeviceIds : []string {"0" },
157+ },
158158 },
159159 },
160160 },
@@ -296,6 +296,12 @@ func TestFillPodDevicesAllocatedByKoord(t *testing.T) {
296296 for _ , test := range tests {
297297 t .Run (test .name , func (t * testing.T ) {
298298 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+ })
299305 assert .Equal (t , test .expectedResult , test .response )
300306 })
301307 }
0 commit comments