Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
Signed-off-by: bobz965 <[email protected]>
  • Loading branch information
bobz965 committed Sep 22, 2024
1 parent c4279ec commit fad9d2f
Showing 1 changed file with 28 additions and 11 deletions.
39 changes: 28 additions & 11 deletions pkg/util/k8s_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@ func TestGetPodIPs(t *testing.T) {
}
})
}

}

func TestServiceClusterIPs(t *testing.T) {
Expand Down Expand Up @@ -324,7 +323,7 @@ func TestUpdateNodeLabels(t *testing.T) {
{
name: "node_with_labels",
cs: nodeClient,
node: "node",
node: "node1",
labels: map[string]any{
"key1": "value1",
},
Expand All @@ -333,21 +332,27 @@ func TestUpdateNodeLabels(t *testing.T) {
{
name: "node_with_nil_labels",
cs: nodeClient,
node: "node",
node: "node2",
labels: map[string]any{},
exp: nil,
},
}
for _, tt := range tests {
// create a node
client.CoreV1().Nodes().Create(context.Background(), &v1.Node{
node, err := client.CoreV1().Nodes().Create(context.Background(), &v1.Node{
ObjectMeta: metav1.ObjectMeta{
Name: tt.node,
},
}, metav1.CreateOptions{})
require.NoError(t, err)
require.NotNil(t, node)
t.Run(tt.name, func(t *testing.T) {
err := UpdateNodeLabels(tt.cs, tt.node, tt.labels)
if err != tt.exp {
if tt.exp == nil {
require.NoError(t, err)
return
}
if errors.Is(err, tt.exp) {
t.Errorf("got %v, want %v", err, tt.exp)
}
})
Expand All @@ -367,7 +372,7 @@ func TestUpdateNodeAnnotations(t *testing.T) {
{
name: "node_with_annotations",
cs: nodeClient,
node: "node",
node: "node1",
annotations: map[string]any{
"key1": "value1",
},
Expand All @@ -376,21 +381,27 @@ func TestUpdateNodeAnnotations(t *testing.T) {
{
name: "node_with_nil_annotations",
cs: nodeClient,
node: "node",
node: "node2",
annotations: map[string]any{},
exp: nil,
},
}
for _, tt := range tests {
// create a node
client.CoreV1().Nodes().Create(context.Background(), &v1.Node{
node, err := client.CoreV1().Nodes().Create(context.Background(), &v1.Node{
ObjectMeta: metav1.ObjectMeta{
Name: tt.node,
},
}, metav1.CreateOptions{})
require.NoError(t, err)
require.NotNil(t, node)
t.Run(tt.name, func(t *testing.T) {
err := UpdateNodeAnnotations(tt.cs, tt.node, tt.annotations)
if err != tt.exp {
if tt.exp == nil {
require.NoError(t, err)
return
}
if errors.Is(err, tt.exp) {
t.Errorf("got %v, want %v", err, tt.exp)
}
})
Expand All @@ -417,14 +428,20 @@ func TestNodeMergePatch(t *testing.T) {
}
for _, tt := range tests {
// create a node
client.CoreV1().Nodes().Create(context.Background(), &v1.Node{
node, err := client.CoreV1().Nodes().Create(context.Background(), &v1.Node{
ObjectMeta: metav1.ObjectMeta{
Name: tt.node,
},
}, metav1.CreateOptions{})
require.NoError(t, err)
require.NotNil(t, node)
t.Run(tt.name, func(t *testing.T) {
err := nodeMergePatch(tt.cs, tt.node, tt.patch)
if err != tt.exp {
if tt.exp == nil {
require.NoError(t, err)
return
}
if errors.Is(err, tt.exp) {
t.Errorf("got %v, want %v", err, tt.exp)
}
})
Expand Down

0 comments on commit fad9d2f

Please sign in to comment.