Skip to content

Commit 34193cc

Browse files
authored
Improve git_commits.go coverage (google#1760)
1 parent 38622b1 commit 34193cc

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

github/git_commits_test.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,20 @@ func TestGitService_GetCommit(t *testing.T) {
137137
if !reflect.DeepEqual(commit, want) {
138138
t.Errorf("Git.GetCommit returned %+v, want %+v", commit, want)
139139
}
140+
141+
const methodName = "GetCommit"
142+
testBadOptions(t, methodName, func() (err error) {
143+
_, _, err = client.Git.GetCommit(ctx, "\n", "\n", "\n")
144+
return err
145+
})
146+
147+
testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
148+
got, resp, err := client.Git.GetCommit(ctx, "o", "r", "s")
149+
if got != nil {
150+
t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
151+
}
152+
return resp, err
153+
})
140154
}
141155

142156
func TestGitService_GetCommit_invalidOwner(t *testing.T) {
@@ -185,6 +199,20 @@ func TestGitService_CreateCommit(t *testing.T) {
185199
if !reflect.DeepEqual(commit, want) {
186200
t.Errorf("Git.CreateCommit returned %+v, want %+v", commit, want)
187201
}
202+
203+
const methodName = "CreateCommit"
204+
testBadOptions(t, methodName, func() (err error) {
205+
_, _, err = client.Git.CreateCommit(ctx, "\n", "\n", input)
206+
return err
207+
})
208+
209+
testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
210+
got, resp, err := client.Git.CreateCommit(ctx, "o", "r", input)
211+
if got != nil {
212+
t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
213+
}
214+
return resp, err
215+
})
188216
}
189217

190218
func TestGitService_CreateSignedCommit(t *testing.T) {
@@ -230,7 +258,22 @@ func TestGitService_CreateSignedCommit(t *testing.T) {
230258
if !reflect.DeepEqual(commit, want) {
231259
t.Errorf("Git.CreateCommit returned %+v, want %+v", commit, want)
232260
}
261+
262+
const methodName = "CreateCommit"
263+
testBadOptions(t, methodName, func() (err error) {
264+
_, _, err = client.Git.CreateCommit(ctx, "\n", "\n", input)
265+
return err
266+
})
267+
268+
testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
269+
got, resp, err := client.Git.CreateCommit(ctx, "o", "r", input)
270+
if got != nil {
271+
t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
272+
}
273+
return resp, err
274+
})
233275
}
276+
234277
func TestGitService_CreateSignedCommitWithInvalidParams(t *testing.T) {
235278
client, _, _, teardown := setup()
236279
defer teardown()

0 commit comments

Comments
 (0)