github.com/wolfi-dev/wolfictl@v0.16.11/pkg/configs/advisory/v2/fixed_test.go (about)

     1  package v2
     2  
     3  import "testing"
     4  
     5  func TestFixed_Validate(t *testing.T) {
     6  	t.Run("valid", func(t *testing.T) {
     7  		f := Fixed{
     8  			FixedVersion: "1.2.3-r4",
     9  		}
    10  		if err := f.Validate(); err != nil {
    11  			t.Errorf("unexpected error: %v", err)
    12  		}
    13  	})
    14  
    15  	t.Run("invalid", func(t *testing.T) {
    16  		cases := []struct {
    17  			name string
    18  			f    Fixed
    19  		}{
    20  			{
    21  				name: "empty",
    22  				f:    Fixed{},
    23  			},
    24  			{
    25  				name: "missing epoch",
    26  				f: Fixed{
    27  					FixedVersion: "1.2.3",
    28  				},
    29  			},
    30  		}
    31  
    32  		for _, tt := range cases {
    33  			t.Run(tt.name, func(t *testing.T) {
    34  				if err := tt.f.Validate(); err == nil {
    35  					t.Errorf("expected error, got nil")
    36  				}
    37  			})
    38  		}
    39  	})
    40  }