Skip to content

Commit

Permalink
fix: Add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
ishaansehgal99 committed Feb 28, 2024
1 parent 4d0b9cb commit c0673d0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/controllers/workspace_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ func (c *WorkspaceReconciler) getAllQualifiedNodes(ctx context.Context, wObj *ka
if err != nil {
return nil, err
}
fmt.Println(nodeList.Items)
if len(nodeList.Items) == 0 {
klog.InfoS("no current nodes match the workspace resource spec", "workspace", klog.KObj(wObj))
return nil, nil
Expand Down
12 changes: 12 additions & 0 deletions pkg/controllers/workspace_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"reflect"
"sort"
"testing"
"time"

"github.com/aws/karpenter-core/pkg/apis/v1alpha5"
"github.com/azure/kaito/api/v1alpha1"
Expand Down Expand Up @@ -492,6 +493,17 @@ func TestGetAllQualifiedNodes(t *testing.T) {
"Gets all qualified nodes": {
callMocks: func(c *utils.MockClient) {
nodeList := utils.MockNodeList
deletedNode := corev1.Node{
ObjectMeta: v1.ObjectMeta{
Name: "node4",
Labels: map[string]string{
corev1.LabelInstanceTypeStable: "Standard_NC12s_v3",
},
DeletionTimestamp: &v1.Time{Time: time.Now()}, // This sets the current time as the deletion timestamp
},
}
nodeList.Items = append(nodeList.Items, deletedNode)

relevantMap := c.CreateMapWithType(nodeList)
//insert node objects into the map
for _, obj := range utils.MockNodeList.Items {
Expand Down

0 comments on commit c0673d0

Please sign in to comment.