(t *testing.T)
| 123 | } |
| 124 | |
| 125 | func TestParseArtifactNumber(t *testing.T) { |
| 126 | tests := []struct { |
| 127 | name string |
| 128 | arg string |
| 129 | want int |
| 130 | wantErr string |
| 131 | }{ |
| 132 | { |
| 133 | name: "a number", |
| 134 | arg: "2", |
| 135 | want: 2, |
| 136 | }, |
| 137 | { |
| 138 | name: "zero", |
| 139 | arg: "0", |
| 140 | wantErr: `invalid artifact number: "0"`, |
| 141 | }, |
| 142 | { |
| 143 | name: "a negative number", |
| 144 | arg: "-2", |
| 145 | wantErr: `invalid artifact number: "-2"`, |
| 146 | }, |
| 147 | { |
| 148 | name: "a number with a hash", |
| 149 | arg: "#2", |
| 150 | wantErr: `invalid artifact number: "#2"`, |
| 151 | }, |
| 152 | { |
| 153 | name: "a name", |
| 154 | arg: "OAuth", |
| 155 | wantErr: `invalid artifact number: "OAuth"`, |
| 156 | }, |
| 157 | } |
| 158 | |
| 159 | for _, tt := range tests { |
| 160 | t.Run(tt.name, func(t *testing.T) { |
| 161 | got, err := ParseArtifactNumber(tt.arg) |
| 162 | |
| 163 | if tt.wantErr != "" { |
| 164 | require.EqualError(t, err, tt.wantErr) |
| 165 | return |
| 166 | } |
| 167 | require.NoError(t, err) |
| 168 | assert.Equal(t, tt.want, got) |
| 169 | }) |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | func TestParseArtifactArgs(t *testing.T) { |
| 174 | // The spec's artifacts 2 and 5 on issue 142, and 1 on issue 137. |
nothing calls this directly
no test coverage detected