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

Function TestGitHubRepo_withParent

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

Source from the content-addressed store, hash-verified

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