(t *testing.T)
| 2342 | } |
| 2343 | |
| 2344 | func Test_generateCompareURL(t *testing.T) { |
| 2345 | tests := []struct { |
| 2346 | name string |
| 2347 | ctx CreateContext |
| 2348 | state shared.IssueMetadataState |
| 2349 | httpStubs func(*testing.T, *httpmock.Registry) |
| 2350 | projectsV1Support gh.ProjectsV1Support |
| 2351 | want string |
| 2352 | wantErr bool |
| 2353 | }{ |
| 2354 | { |
| 2355 | name: "basic", |
| 2356 | ctx: CreateContext{ |
| 2357 | PRRefs: &skipPushRefs{ |
| 2358 | qualifiedHeadRef: shared.NewQualifiedHeadRefWithoutOwner("feature"), |
| 2359 | baseRefs: baseRefs{ |
| 2360 | baseRepo: api.InitRepoHostname(&api.Repository{Name: "REPO", Owner: api.RepositoryOwner{Login: "OWNER"}}, "github.com"), |
| 2361 | baseBranchName: "main", |
| 2362 | }, |
| 2363 | }, |
| 2364 | }, |
| 2365 | want: "https://github.com/OWNER/REPO/compare/main...feature?body=&expand=1", |
| 2366 | wantErr: false, |
| 2367 | }, |
| 2368 | { |
| 2369 | name: "with labels", |
| 2370 | ctx: CreateContext{ |
| 2371 | PRRefs: &skipPushRefs{ |
| 2372 | qualifiedHeadRef: shared.NewQualifiedHeadRefWithoutOwner("b"), |
| 2373 | baseRefs: baseRefs{ |
| 2374 | baseRepo: api.InitRepoHostname(&api.Repository{Name: "REPO", Owner: api.RepositoryOwner{Login: "OWNER"}}, "github.com"), |
| 2375 | baseBranchName: "a", |
| 2376 | }, |
| 2377 | }, |
| 2378 | }, |
| 2379 | state: shared.IssueMetadataState{ |
| 2380 | Labels: []string{"one", "two three"}, |
| 2381 | }, |
| 2382 | want: "https://github.com/OWNER/REPO/compare/a...b?body=&expand=1&labels=one%2Ctwo+three", |
| 2383 | wantErr: false, |
| 2384 | }, |
| 2385 | { |
| 2386 | name: "'/'s in branch names/labels are percent-encoded", |
| 2387 | ctx: CreateContext{ |
| 2388 | PRRefs: &skipPushRefs{ |
| 2389 | qualifiedHeadRef: mustParseQualifiedHeadRef("ORIGINOWNER:feature"), |
| 2390 | baseRefs: baseRefs{ |
| 2391 | baseRepo: api.InitRepoHostname(&api.Repository{Name: "REPO", Owner: api.RepositoryOwner{Login: "UPSTREAMOWNER"}}, "github.com"), |
| 2392 | baseBranchName: "main/trunk", |
| 2393 | }, |
| 2394 | }, |
| 2395 | }, |
| 2396 | want: "https://github.com/UPSTREAMOWNER/REPO/compare/main%2Ftrunk...ORIGINOWNER:feature?body=&expand=1", |
| 2397 | wantErr: false, |
| 2398 | }, |
| 2399 | { |
| 2400 | name: "Any of !'(),; but none of $&+=@ and : in branch names/labels are percent-encoded ", |
| 2401 | /* |
nothing calls this directly
no test coverage detected