github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/cmd/build/version_test.go (about)

     1  package build
     2  
     3  import "testing"
     4  
     5  func TestMakeSemverV2Compliant(t *testing.T) {
     6  	testCases := []struct {
     7  		name     string
     8  		input    string
     9  		expected string
    10  	}{
    11  		{"No hyphen", "v0.29", "0.29.0"},
    12  		{"With hyphen", "v0.29.11-an-error-handling", "0.29.11-an-error-handling"},
    13  		{"With hyphen no patch", "v0.29-an-error-handling", "0.29.0-an-error-handling"},
    14  		{"All digits", "v0.29.1", "0.29.1"},
    15  		{undefined, undefined, undefined},
    16  	}
    17  
    18  	for _, tc := range testCases {
    19  		t.Run(tc.name, func(t *testing.T) {
    20  			output := makeSemverCompliant(tc.input)
    21  			if output != tc.expected {
    22  				t.Errorf("Got %s; expected %s", output, tc.expected)
    23  			}
    24  		})
    25  	}
    26  }