github.com/operator-framework/operator-lifecycle-manager@v0.30.0/pkg/lib/image/image_test.go (about) 1 package image_test 2 3 import ( 4 "testing" 5 6 "github.com/operator-framework/operator-lifecycle-manager/pkg/lib/image" 7 "github.com/stretchr/testify/require" 8 corev1 "k8s.io/api/core/v1" 9 ) 10 11 func TestInferImagePullPolicy(t *testing.T) { 12 tests := []struct { 13 description string 14 img string 15 expectedPolicy corev1.PullPolicy 16 }{ 17 { 18 description: "WithImageTag", 19 img: "my-image:my-tag", 20 expectedPolicy: corev1.PullAlways, 21 }, 22 { 23 description: "WithImageDigest", 24 img: "my-image@sha256:54d626e08c1c802b305dad30b7e54a82f102390cc92c7d4db112048935236e9c", 25 expectedPolicy: corev1.PullIfNotPresent, 26 }, 27 } 28 29 for _, tt := range tests { 30 t.Run(tt.description, func(t *testing.T) { 31 policy := image.InferImagePullPolicy(tt.img) 32 require.Equal(t, tt.expectedPolicy, policy) 33 }) 34 } 35 }