Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
Signed-off-by: kerthcet <[email protected]>
  • Loading branch information
kerthcet committed Jan 23, 2024
1 parent 728e661 commit bfdffa1
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions cmd/nvidia-dra-controller/allocations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@ package main
import (
"testing"

"github.com/NVIDIA/k8s-dra-driver/api/nvidia.com/resource/gpu/nas/v1alpha1"
nascrd "github.com/NVIDIA/k8s-dra-driver/api/nvidia.com/resource/gpu/nas/v1alpha1"
"github.com/stretchr/testify/assert"
)

func Test_PerNodeAllocatedClaims(t *testing.T) {
allocationClaims := &PerNodeAllocatedClaims{
allocations: make(map[string]map[string]v1alpha1.AllocatedDevices),
allocations: make(map[string]map[string]nascrd.AllocatedDevices),
}

// Test Exists()
exists := allocationClaims.Exists("claim-not-exist", "fake-node")
assert.Equal(t, false, exists)

// Test Set()
device1 := v1alpha1.AllocatedDevices{ClaimInfo: &v1alpha1.ClaimInfo{Namespace: "default", Name: "device1"}}
device2 := v1alpha1.AllocatedDevices{ClaimInfo: &v1alpha1.ClaimInfo{Namespace: "default", Name: "device2"}}
device1 := nascrd.AllocatedDevices{ClaimInfo: &nascrd.ClaimInfo{Namespace: "default", Name: "device1"}}
device2 := nascrd.AllocatedDevices{ClaimInfo: &nascrd.ClaimInfo{Namespace: "default", Name: "device2"}}
allocationClaims.Set("fake-claim", "fake-node", device1)
allocationClaims.Set("fake-claim", "fake-node", device2)

Expand All @@ -46,13 +46,13 @@ func Test_PerNodeAllocatedClaims(t *testing.T) {

// Test Remove()
allocationClaims.Remove("fake-claim")
assert.Equal(t, allocationClaims.allocations, map[string]map[string]v1alpha1.AllocatedDevices{})
assert.Equal(t, allocationClaims.allocations, map[string]map[string]nascrd.AllocatedDevices{})

// Test RemoveNode()
allocationClaims.Set("fake-claim", "fake-node-1", device1)
allocationClaims.Set("fake-claim", "fake-node-2", device2)
allocationClaims.RemoveNode("fake-claim", "fake-node-1")
assert.Equal(t, allocationClaims.allocations, map[string]map[string]v1alpha1.AllocatedDevices{"fake-claim": map[string]v1alpha1.AllocatedDevices{"fake-node-2": device2}})
assert.Equal(t, allocationClaims.allocations, map[string]map[string]nascrd.AllocatedDevices{"fake-claim": map[string]nascrd.AllocatedDevices{"fake-node-2": device2}})
allocationClaims.RemoveNode("fake-claim", "fake-node-2")
assert.Equal(t, allocationClaims.allocations, map[string]map[string]v1alpha1.AllocatedDevices{})
assert.Equal(t, allocationClaims.allocations, map[string]map[string]nascrd.AllocatedDevices{})
}

0 comments on commit bfdffa1

Please sign in to comment.