MCPcopy Create free account
hub / github.com/cli/cli / Test_generateCompareURL

Function Test_generateCompareURL

pkg/cmd/pr/create/create_test.go:2764–2994  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2762}
2763
2764func Test_generateCompareURL(t *testing.T) {
2765 tests := []struct {
2766 name string
2767 ctx CreateContext
2768 state shared.IssueMetadataState
2769 httpStubs func(*testing.T, *httpmock.Registry)
2770 projectsV1Support gh.ProjectsV1Support
2771 want string
2772 wantErr bool
2773 }{
2774 {
2775 name: "basic",
2776 ctx: CreateContext{
2777 PRRefs: &skipPushRefs{
2778 qualifiedHeadRef: shared.NewQualifiedHeadRefWithoutOwner("feature"),
2779 baseRefs: baseRefs{
2780 baseRepo: api.InitRepoHostname(&api.Repository{Name: "REPO", Owner: api.RepositoryOwner{Login: "OWNER"}}, "github.com"),
2781 baseBranchName: "main",
2782 },
2783 },
2784 },
2785 want: "https://github.com/OWNER/REPO/compare/main...feature?body=&expand=1",
2786 wantErr: false,
2787 },
2788 {
2789 name: "with labels",
2790 ctx: CreateContext{
2791 PRRefs: &skipPushRefs{
2792 qualifiedHeadRef: shared.NewQualifiedHeadRefWithoutOwner("b"),
2793 baseRefs: baseRefs{
2794 baseRepo: api.InitRepoHostname(&api.Repository{Name: "REPO", Owner: api.RepositoryOwner{Login: "OWNER"}}, "github.com"),
2795 baseBranchName: "a",
2796 },
2797 },
2798 },
2799 state: shared.IssueMetadataState{
2800 Labels: []string{"one", "two three"},
2801 },
2802 want: "https://github.com/OWNER/REPO/compare/a...b?body=&expand=1&labels=one%2Ctwo+three",
2803 wantErr: false,
2804 },
2805 {
2806 name: "'/'s in branch names/labels are percent-encoded",
2807 ctx: CreateContext{
2808 PRRefs: &skipPushRefs{
2809 qualifiedHeadRef: mustParseQualifiedHeadRef("ORIGINOWNER:feature"),
2810 baseRefs: baseRefs{
2811 baseRepo: api.InitRepoHostname(&api.Repository{Name: "REPO", Owner: api.RepositoryOwner{Login: "UPSTREAMOWNER"}}, "github.com"),
2812 baseBranchName: "main/trunk",
2813 },
2814 },
2815 },
2816 want: "https://github.com/UPSTREAMOWNER/REPO/compare/main%2Ftrunk...ORIGINOWNER:feature?body=&expand=1",
2817 wantErr: false,
2818 },
2819 {
2820 name: "Any of !'(),; but none of $&+=@ and : in branch names/labels are percent-encoded ",
2821 /*

Callers

nothing calls this directly

Calls 12

ExcludeMethod · 0.95
RegisterMethod · 0.95
VerifyMethod · 0.95
InitRepoHostnameFunction · 0.92
GraphQLFunction · 0.92
StringResponseFunction · 0.92
NewClientFromHTTPFunction · 0.92
generateCompareURLFunction · 0.85
RunMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected