Skip to content

Commit 4a096f2

Browse files
committed
Fixed unit tests
1 parent 7e95b69 commit 4a096f2

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

pkg/storage/pv_creator_test.go

+8-6
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ package storage
2424

2525
import (
2626
"context"
27+
"encoding/json"
2728
"testing"
2829

2930
"github.com/stretchr/testify/assert"
@@ -83,16 +84,17 @@ func TestCreateValidEndpointList(t *testing.T) {
8384
}
8485
}
8586

86-
// TestCreateNodeAffinity tests createNodeAffinity.
87-
func TestCreateNodeAffinity(t *testing.T) {
87+
// TestCreateNodeSelector tests createNodeSelector.
88+
func TestCreateNodeSelector(t *testing.T) {
8889
tests := map[string]string{
89-
"foo": "{\"requiredDuringSchedulingIgnoredDuringExecution\":{\"nodeSelectorTerms\":[{\"matchExpressions\":[{\"key\":\"kubernetes.io/hostname\",\"operator\":\"In\",\"values\":[\"foo\"]}]}]}}",
90-
"bar": "{\"requiredDuringSchedulingIgnoredDuringExecution\":{\"nodeSelectorTerms\":[{\"matchExpressions\":[{\"key\":\"kubernetes.io/hostname\",\"operator\":\"In\",\"values\":[\"bar\"]}]}]}}",
90+
"foo": "{\"nodeSelectorTerms\":[{\"matchExpressions\":[{\"key\":\"kubernetes.io/hostname\",\"operator\":\"In\",\"values\":[\"foo\"]}]}]}",
91+
"bar": "{\"nodeSelectorTerms\":[{\"matchExpressions\":[{\"key\":\"kubernetes.io/hostname\",\"operator\":\"In\",\"values\":[\"bar\"]}]}]}",
9192
}
9293
for input, expected := range tests {
93-
output, err := createNodeAffinity(input)
94+
sel := createNodeSelector(input)
95+
output, err := json.Marshal(sel)
9496
assert.NoError(t, err)
95-
assert.Equal(t, expected, output, "Input: '%s'", input)
97+
assert.Equal(t, expected, string(output), "Input: '%s'", input)
9698
}
9799
}
98100

0 commit comments

Comments
 (0)