Files
Memoh/internal/workspace/gpu_labels_test.go
T
Ming Lin 4d3f2de7e2 feat: Add GPU CDI support for workspace containers (#332)
* feat: add CDI GPU support for workspace containers

* feat: expose GPU CDI settings in bot container UI

* feat: move GPU settings into advanced container options

* docs: document advanced CDI device configuration
2026-04-10 14:52:17 +08:00

30 lines
728 B
Go

package workspace
import (
"reflect"
"testing"
)
func TestWorkspaceCDIDevicesLabelRoundTrip(t *testing.T) {
t.Parallel()
devices := []string{" nvidia.com/gpu=0 ", "amd.com/gpu=1", "nvidia.com/gpu=0"}
value := workspaceCDIDevicesLabelValue(devices)
got := workspaceCDIDevicesFromLabels(map[string]string{
WorkspaceCDIDevicesLabelKey: value,
})
want := []string{"nvidia.com/gpu=0", "amd.com/gpu=1"}
if !reflect.DeepEqual(got, want) {
t.Fatalf("expected devices %v, got %v", want, got)
}
}
func TestWorkspaceCDIDevicesFromLabelsIgnoresMissingValue(t *testing.T) {
t.Parallel()
if got := workspaceCDIDevicesFromLabels(nil); len(got) != 0 {
t.Fatalf("expected empty devices for nil labels, got %v", got)
}
}