MCPcopy Index your code
hub / github.com/google/go-github / TestRepositoriesService_GetCommit

Function TestRepositoriesService_GetCommit

github/repos_commits_test.go:70–159  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

68}
69
70func TestRepositoriesService_GetCommit(t *testing.T) {
71 t.Parallel()
72 client, mux, _ := setup(t)
73
74 mux.HandleFunc("/repos/o/r/commits/s", func(w http.ResponseWriter, r *http.Request) {
75 testMethod(t, r, "GET")
76 testFormValues(t, r, values{"per_page": "2", "page": "2"})
77 fmt.Fprint(w, `{
78 "sha": "s",
79 "commit": { "message": "m" },
80 "author": { "login": "l" },
81 "committer": { "login": "l" },
82 "parents": [ { "sha": "s" } ],
83 "stats": { "additions": 104, "deletions": 4, "total": 108 },
84 "files": [
85 {
86 "filename": "f",
87 "additions": 10,
88 "deletions": 2,
89 "changes": 12,
90 "status": "s",
91 "patch": "p",
92 "blob_url": "b",
93 "raw_url": "r",
94 "contents_url": "c"
95 }
96 ]
97 }`)
98 })
99
100 opts := &ListOptions{Page: 2, PerPage: 2}
101 ctx := t.Context()
102 commit, _, err := client.Repositories.GetCommit(ctx, "o", "r", "s", opts)
103 if err != nil {
104 t.Errorf("Repositories.GetCommit returned error: %v", err)
105 }
106
107 want := &RepositoryCommit{
108 SHA: Ptr("s"),
109 Commit: &Commit{
110 Message: Ptr("m"),
111 },
112 Author: &User{
113 Login: Ptr("l"),
114 },
115 Committer: &User{
116 Login: Ptr("l"),
117 },
118 Parents: []*Commit{
119 {
120 SHA: Ptr("s"),
121 },
122 },
123 Stats: &CommitStats{
124 Additions: Ptr(104),
125 Deletions: Ptr(4),
126 Total: Ptr(108),
127 },

Callers

nothing calls this directly

Calls 8

testMethodFunction · 0.85
testFormValuesFunction · 0.85
testBadOptionsFunction · 0.85
EqualMethod · 0.80
setupFunction · 0.70
PtrFunction · 0.70
GetCommitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…