(t *testing.T)
| 189 | } |
| 190 | |
| 191 | func TestParseProjectURL(t *testing.T) { |
| 192 | tests := []struct { |
| 193 | name string |
| 194 | url string |
| 195 | expectedScope string |
| 196 | expectedOwner string |
| 197 | expectedNumber int |
| 198 | shouldErr bool |
| 199 | }{ |
| 200 | { |
| 201 | name: "org project", |
| 202 | url: "https://github.com/orgs/myorg/projects/123", |
| 203 | expectedScope: "orgs", |
| 204 | expectedOwner: "myorg", |
| 205 | expectedNumber: 123, |
| 206 | shouldErr: false, |
| 207 | }, |
| 208 | { |
| 209 | name: "user project", |
| 210 | url: "https://github.com/users/myuser/projects/456", |
| 211 | expectedScope: "users", |
| 212 | expectedOwner: "myuser", |
| 213 | expectedNumber: 456, |
| 214 | shouldErr: false, |
| 215 | }, |
| 216 | { |
| 217 | name: "invalid URL", |
| 218 | url: "https://github.com/myorg/myrepo", |
| 219 | shouldErr: true, |
| 220 | }, |
| 221 | { |
| 222 | name: "empty URL", |
| 223 | url: "", |
| 224 | shouldErr: true, |
| 225 | }, |
| 226 | } |
| 227 | |
| 228 | for _, tt := range tests { |
| 229 | t.Run(tt.name, func(t *testing.T) { |
| 230 | result, err := parseProjectURL(tt.url) |
| 231 | if tt.shouldErr { |
| 232 | assert.Error(t, err, "Should return error for invalid URL") |
| 233 | } else { |
| 234 | require.NoError(t, err, "Should not return error for valid URL") |
| 235 | assert.Equal(t, tt.expectedScope, result.scope, "Scope should match") |
| 236 | assert.Equal(t, tt.expectedOwner, result.ownerLogin, "Owner should match") |
| 237 | assert.Equal(t, tt.expectedNumber, result.projectNumber, "Project number should match") |
| 238 | } |
| 239 | }) |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | func TestEnsureSingleSelectOptionBefore(t *testing.T) { |
| 244 | tests := []struct { |
nothing calls this directly
no test coverage detected