github.com/olli-ai/jx/v2@v2.0.400-0.20210921045218-14731b4dd448/pkg/kube/validate_test.go (about) 1 // +build unit 2 3 package kube_test 4 5 import ( 6 "testing" 7 8 "github.com/olli-ai/jx/v2/pkg/kube" 9 "github.com/stretchr/testify/assert" 10 ) 11 12 func TestValidateName(t *testing.T) { 13 t.Parallel() 14 err := kube.ValidateName("test") 15 assert.NoError(t, err, "Should not error") 16 } 17 18 func TestValidateNameTypeError(t *testing.T) { 19 t.Parallel() 20 err := kube.ValidateName(1) 21 assert.Error(t, err, "Should error") 22 } 23 24 func TestValidateNameEmptyError(t *testing.T) { 25 t.Parallel() 26 err := kube.ValidateName("") 27 assert.Error(t, err, "Should error") 28 } 29 30 func TestValidNameOption(t *testing.T) { 31 t.Parallel() 32 err := kube.ValidNameOption("test-option", "test-value") 33 assert.NoError(t, err, "Should not error") 34 } 35 36 func TestValidNameOptionEmpty(t *testing.T) { 37 t.Parallel() 38 err := kube.ValidNameOption("", "") 39 assert.NoError(t, err, "Should not error") 40 } 41 42 func TestValidNameOptionInvalidSubdomainError(t *testing.T) { 43 t.Parallel() 44 err := kube.ValidNameOption("", "not a valid subdomain") 45 assert.Error(t, err, "Should error") 46 }