| 57 | } |
| 58 | |
| 59 | func TestIsValid(t *testing.T) { |
| 60 | tests := []struct { |
| 61 | ref string |
| 62 | want bool |
| 63 | }{ |
| 64 | {"v1.0.0", true}, |
| 65 | {"1.0.0", true}, |
| 66 | {"v1.0", true}, |
| 67 | {"v1", true}, |
| 68 | {"v1.0.0-beta", true}, |
| 69 | {"v1.0.0+20230101", true}, |
| 70 | {"main", false}, |
| 71 | {"feature-branch", false}, |
| 72 | {"abc123def456", false}, |
| 73 | } |
| 74 | for _, tt := range tests { |
| 75 | t.Run(tt.ref, func(t *testing.T) { |
| 76 | got := IsValid(tt.ref) |
| 77 | if got != tt.want { |
| 78 | t.Errorf("IsValid(%q) = %v, want %v", tt.ref, got, tt.want) |
| 79 | } |
| 80 | }) |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | func TestParseVersion(t *testing.T) { |
| 85 | tests := []struct { |