github.com/docker/compose-on-kubernetes@v0.5.0/cmd/installer/main_test.go (about) 1 package main 2 3 import ( 4 "fmt" 5 "testing" 6 7 "github.com/stretchr/testify/assert" 8 corev1types "k8s.io/api/core/v1" 9 ) 10 11 // TestParsePullPolicyValid verifies that parsing a valid pull policy works 12 func TestParsePullPolicyValid(t *testing.T) { 13 for _, pp := range []corev1types.PullPolicy{corev1types.PullAlways, corev1types.PullNever, corev1types.PullIfNotPresent} { 14 res, err := parsePullPolicy(string(pp)) 15 assert.NoError(t, err) 16 assert.Equal(t, res, pp) 17 } 18 } 19 20 // TestParsePullPolicyInValid verifies that parsing an invalid pull policy 21 // triggers an error 22 func TestParsePullPolicyInValid(t *testing.T) { 23 for _, pp := range []string{"always", "invalid", ""} { 24 res, err := parsePullPolicy(string(pp)) 25 assert.EqualError(t, err, fmt.Sprintf("invalid pull policy: % q", pp)) 26 assert.Empty(t, res) 27 } 28 }