(t *testing.T)
| 65 | } |
| 66 | |
| 67 | func TestReleaseVersion(t *testing.T) { |
| 68 | t.Parallel() |
| 69 | |
| 70 | tests := []struct { |
| 71 | name string |
| 72 | tagName string |
| 73 | want string |
| 74 | wantErr bool |
| 75 | }{ |
| 76 | {name: "v prefix", tagName: "v1.2.3", want: "1.2.3"}, |
| 77 | {name: "no prefix", tagName: "0.1.0", want: "0.1.0"}, |
| 78 | {name: "whitespace", tagName: " v2.0.0 ", want: "2.0.0"}, |
| 79 | {name: "empty", tagName: "", wantErr: true}, |
| 80 | {name: "non numeric", tagName: "latest", wantErr: true}, |
| 81 | } |
| 82 | for _, tt := range tests { |
| 83 | t.Run(tt.name, func(t *testing.T) { |
| 84 | t.Parallel() |
| 85 | |
| 86 | version, errVersion := ReleaseVersion(Release{TagName: tt.tagName}) |
| 87 | if tt.wantErr { |
| 88 | if errVersion == nil { |
| 89 | t.Fatalf("ReleaseVersion(%q) error = nil", tt.tagName) |
| 90 | } |
| 91 | return |
| 92 | } |
| 93 | if errVersion != nil { |
| 94 | t.Fatalf("ReleaseVersion(%q) error = %v", tt.tagName, errVersion) |
| 95 | } |
| 96 | if version != tt.want { |
| 97 | t.Fatalf("ReleaseVersion(%q) = %q, want %q", tt.tagName, version, tt.want) |
| 98 | } |
| 99 | }) |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | func TestParseChecksumsAndVerifyChecksum(t *testing.T) { |
| 104 | t.Parallel() |
nothing calls this directly
no test coverage detected