github.com/helmwave/helmwave@v0.36.4-0.20240509190856-b35563eba4c6/pkg/release/uniqname/uniqname_test.go (about)

     1  package uniqname_test
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/helmwave/helmwave/pkg/release/uniqname"
     7  	"github.com/stretchr/testify/suite"
     8  )
     9  
    10  type ValidateTestSuite struct {
    11  	suite.Suite
    12  }
    13  
    14  func (s *ValidateTestSuite) TestGood() {
    15  	data := []string{
    16  		"my@test",
    17  		"my-release@test-1",
    18  	}
    19  
    20  	for _, d := range data {
    21  		s.NoError(uniqname.UniqName(d).Validate())
    22  	}
    23  }
    24  
    25  func (s *ValidateTestSuite) TestBad() {
    26  	data := []string{
    27  		"my-release",
    28  		"my",
    29  		"my@",
    30  		"my@-",
    31  		"my@ ",
    32  		"@name",
    33  		"@",
    34  		"@-",
    35  		"-@-",
    36  	}
    37  
    38  	for _, d := range data {
    39  		u := uniqname.UniqName(d)
    40  		var e *uniqname.ValidationError
    41  		s.ErrorAs(u.Validate(), &e)
    42  		s.Equal(d, e.Uniq)
    43  	}
    44  }
    45  
    46  func TestValidateTestSuite(t *testing.T) {
    47  	t.Parallel()
    48  	suite.Run(t, new(ValidateTestSuite))
    49  }