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

Function TestGitHubRepo_withParent

api/queries_repo_test.go:79–141  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

77}
78
79func TestGitHubRepo_withParent(t *testing.T) {
80 httpReg := &httpmock.Registry{}
81 defer httpReg.Verify(t)
82
83 httpReg.Register(
84 httpmock.GraphQL(`query RepositoryInfo\b`),
85 httpmock.StringResponse(`
86 { "data": { "repository": {
87 "id": "REPOID",
88 "name": "REPO",
89 "owner": {"login": "OWNER"},
90 "sshUrl": "git@github.com:OWNER/REPO.git",
91 "hasIssuesEnabled": true,
92 "description": "",
93 "hasWikiEnabled": false,
94 "viewerPermission": "READ",
95 "defaultBranchRef": {"name": "main"},
96 "parent": {
97 "id": "PARENTID",
98 "name": "PARENT-REPO",
99 "owner": {"login": "PARENT-OWNER"},
100 "sshUrl": "org-5678@github.com:PARENT-OWNER/PARENT-REPO.git",
101 "hasIssuesEnabled": true,
102 "description": "parent repo",
103 "hasWikiEnabled": true,
104 "viewerPermission": "READ",
105 "defaultBranchRef": {"name": "develop"}
106 },
107 "mergeCommitAllowed": false,
108 "rebaseMergeAllowed": false,
109 "squashMergeAllowed": true
110 } } }`))
111
112 client := newTestClient(httpReg)
113 repo, err := GitHubRepo(client, ghrepo.New("OWNER", "REPO"))
114 require.NoError(t, err)
115 wantParent := &Repository{
116 ID: "PARENTID",
117 Name: "PARENT-REPO",
118 Owner: RepositoryOwner{Login: "PARENT-OWNER"},
119 SSHURL: "org-5678@github.com:PARENT-OWNER/PARENT-REPO.git",
120 HasIssuesEnabled: true,
121 Description: "parent repo",
122 HasWikiEnabled: true,
123 ViewerPermission: "READ",
124 DefaultBranchRef: BranchRef{Name: "develop"},
125 hostname: "github.com",
126 }
127 assert.Equal(t, &Repository{
128 ID: "REPOID",
129 Name: "REPO",
130 Owner: RepositoryOwner{Login: "OWNER"},
131 SSHURL: "git@github.com:OWNER/REPO.git",
132 HasIssuesEnabled: true,
133 ViewerPermission: "READ",
134 DefaultBranchRef: BranchRef{Name: "main"},
135 Parent: wantParent,
136 SquashMergeAllowed: true,

Callers

nothing calls this directly

Calls 10

VerifyMethod · 0.95
RegisterMethod · 0.95
GraphQLFunction · 0.92
StringResponseFunction · 0.92
NewFunction · 0.92
newTestClientFunction · 0.85
GitHubRepoFunction · 0.85
EqualMethod · 0.80
ViewerCanPushMethod · 0.80
ViewerCanTriageMethod · 0.80

Tested by

no test coverage detected