Skip to content

Commit

Permalink
Fixed unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ewoutp committed Aug 27, 2018
1 parent 7e95b69 commit 4a096f2
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions pkg/storage/pv_creator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ package storage

import (
"context"
"encoding/json"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -83,16 +84,17 @@ func TestCreateValidEndpointList(t *testing.T) {
}
}

// TestCreateNodeAffinity tests createNodeAffinity.
func TestCreateNodeAffinity(t *testing.T) {
// TestCreateNodeSelector tests createNodeSelector.
func TestCreateNodeSelector(t *testing.T) {
tests := map[string]string{
"foo": "{\"requiredDuringSchedulingIgnoredDuringExecution\":{\"nodeSelectorTerms\":[{\"matchExpressions\":[{\"key\":\"kubernetes.io/hostname\",\"operator\":\"In\",\"values\":[\"foo\"]}]}]}}",
"bar": "{\"requiredDuringSchedulingIgnoredDuringExecution\":{\"nodeSelectorTerms\":[{\"matchExpressions\":[{\"key\":\"kubernetes.io/hostname\",\"operator\":\"In\",\"values\":[\"bar\"]}]}]}}",
"foo": "{\"nodeSelectorTerms\":[{\"matchExpressions\":[{\"key\":\"kubernetes.io/hostname\",\"operator\":\"In\",\"values\":[\"foo\"]}]}]}",
"bar": "{\"nodeSelectorTerms\":[{\"matchExpressions\":[{\"key\":\"kubernetes.io/hostname\",\"operator\":\"In\",\"values\":[\"bar\"]}]}]}",
}
for input, expected := range tests {
output, err := createNodeAffinity(input)
sel := createNodeSelector(input)
output, err := json.Marshal(sel)
assert.NoError(t, err)
assert.Equal(t, expected, output, "Input: '%s'", input)
assert.Equal(t, expected, string(output), "Input: '%s'", input)
}
}

Expand Down

0 comments on commit 4a096f2

Please sign in to comment.