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

Function TestGitHubRepo_success

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

Source from the content-addressed store, hash-verified

31}
32
33func TestGitHubRepo_success(t *testing.T) {
34 httpReg := &httpmock.Registry{}
35 defer httpReg.Verify(t)
36
37 httpReg.Register(
38 httpmock.GraphQL(`query RepositoryInfo\b`),
39 httpmock.StringResponse(`
40 { "data": { "repository": {
41 "id": "REPOID",
42 "databaseId": 1234,
43 "name": "REPO",
44 "owner": {"login": "OWNER"},
45 "sshUrl": "org-1234@github.com:OWNER/REPO.git",
46 "hasIssuesEnabled": true,
47 "description": "a cool repo",
48 "hasWikiEnabled": true,
49 "viewerPermission": "ADMIN",
50 "defaultBranchRef": {"name": "main"},
51 "parent": null,
52 "mergeCommitAllowed": true,
53 "rebaseMergeAllowed": true,
54 "squashMergeAllowed": false
55 } } }`))
56
57 client := newTestClient(httpReg)
58 repo, err := GitHubRepo(client, ghrepo.New("OWNER", "REPO"))
59 require.NoError(t, err)
60 assert.Equal(t, &Repository{
61 ID: "REPOID",
62 DatabaseID: 1234,
63 Name: "REPO",
64 Owner: RepositoryOwner{Login: "OWNER"},
65 SSHURL: "org-1234@github.com:OWNER/REPO.git",
66 HasIssuesEnabled: true,
67 Description: "a cool repo",
68 HasWikiEnabled: true,
69 ViewerPermission: "ADMIN",
70 DefaultBranchRef: BranchRef{Name: "main"},
71 MergeCommitAllowed: true,
72 RebaseMergeAllowed: true,
73 hostname: "github.com",
74 }, repo)
75 assert.True(t, repo.ViewerCanPush())
76 assert.True(t, repo.ViewerCanTriage())
77}
78
79func TestGitHubRepo_withParent(t *testing.T) {
80 httpReg := &httpmock.Registry{}

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