MCPcopy
hub / github.com/cli/cli / TestGitHubRepo_withParent

Function TestGitHubRepo_withParent

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

Source from the content-addressed store, hash-verified

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

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