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

Function Test_generateCompareURL

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

Source from the content-addressed store, hash-verified

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

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