MCPcopy Index your code
hub / github.com/cli/cli / TestGitHubRepo_success

Function TestGitHubRepo_success

api/queries_repo_test.go:33–73  ·  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 "name": "REPO",
43 "owner": {"login": "OWNER"},
44 "hasIssuesEnabled": true,
45 "description": "a cool repo",
46 "hasWikiEnabled": true,
47 "viewerPermission": "ADMIN",
48 "defaultBranchRef": {"name": "main"},
49 "parent": null,
50 "mergeCommitAllowed": true,
51 "rebaseMergeAllowed": true,
52 "squashMergeAllowed": false
53 } } }`))
54
55 client := newTestClient(httpReg)
56 repo, err := GitHubRepo(client, ghrepo.New("OWNER", "REPO"))
57 require.NoError(t, err)
58 assert.Equal(t, &Repository{
59 ID: "REPOID",
60 Name: "REPO",
61 Owner: RepositoryOwner{Login: "OWNER"},
62 HasIssuesEnabled: true,
63 Description: "a cool repo",
64 HasWikiEnabled: true,
65 ViewerPermission: "ADMIN",
66 DefaultBranchRef: BranchRef{Name: "main"},
67 MergeCommitAllowed: true,
68 RebaseMergeAllowed: true,
69 hostname: "github.com",
70 }, repo)
71 assert.True(t, repo.ViewerCanPush())
72 assert.True(t, repo.ViewerCanTriage())
73}
74
75func TestGitHubRepo_withParent(t *testing.T) {
76 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