Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ linters:
- commentFormatting
- deprecatedComment
- paramTypeCombine
unparam:
check-exported: true
goheader:
values:
regexp:
Expand Down
7 changes: 7 additions & 0 deletions github/pulls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,13 @@ func TestPullRequestsService_Edit(t *testing.T) {
return err
})
}
testNewRequestAndDoFailure(t, "Edit", client, func() (*Response, error) {
got, resp, err := client.PullRequests.Edit(t.Context(), "o", "r", 1, &PullRequest{})
if got != nil {
t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", "Edit", got)
}
return resp, err
})
}

func TestPullRequestsService_Edit_invalidOwner(t *testing.T) {
Expand Down
7 changes: 7 additions & 0 deletions github/repos_releases_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,13 @@ func TestRepositoriesService_UploadReleaseAsset(t *testing.T) {
return err
})
}
testNewRequestAndDoFailure(t, "UploadReleaseAsset", client, func() (*Response, error) {
got, resp, err := client.Repositories.UploadReleaseAsset(t.Context(), "o", "r", 1, defaultUploadOptions, openTestFile(t, "upload.txt", "Upload me !\n"))
if got != nil {
t.Errorf("testNewRequestAndDoFailure UploadReleaseAsset = %#v, want nil", got)
}
return resp, err
})
}

func TestRepositoryReleaseRequest_Marshal(t *testing.T) {
Expand Down
56 changes: 56 additions & 0 deletions github/search_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ func TestSearchService_Repositories(t *testing.T) {
if !cmp.Equal(result, want) {
t.Errorf("Search.Repositories returned %+v, want %+v", result, want)
}
const methodName = "Repositories"
testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
got, resp, err := client.Search.Repositories(ctx, "blah", opts)
if got != nil {
t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
}
return resp, err
})
}

func TestSearchService_Repositories_coverage(t *testing.T) {
Expand Down Expand Up @@ -171,6 +179,14 @@ func TestSearchService_Topics(t *testing.T) {
if !cmp.Equal(result, want) {
t.Errorf("Search.Topics returned %+v, want %+v", result, want)
}
const methodName = "Topics"
testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
got, resp, err := client.Search.Topics(ctx, "blah", opts)
if got != nil {
t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
}
return resp, err
})
}

func TestSearchService_Topics_coverage(t *testing.T) {
Expand Down Expand Up @@ -216,6 +232,14 @@ func TestSearchService_Commits(t *testing.T) {
if !cmp.Equal(result, want) {
t.Errorf("Search.Commits returned %+v, want %+v", result, want)
}
const methodName = "Commits"
testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
got, resp, err := client.Search.Commits(ctx, "blah", opts)
if got != nil {
t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
}
return resp, err
})
}

func TestSearchService_Commits_coverage(t *testing.T) {
Expand Down Expand Up @@ -263,6 +287,14 @@ func TestSearchService_Issues(t *testing.T) {
if !cmp.Equal(result, want) {
t.Errorf("Search.Issues returned %+v, want %+v", result, want)
}
const methodName = "Issues"
testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
got, resp, err := client.Search.Issues(ctx, "blah", opts)
if got != nil {
t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
}
return resp, err
})
}

func TestSearchService_Issues_advancedSearch(t *testing.T) {
Expand Down Expand Up @@ -422,6 +454,14 @@ func TestSearchService_Users(t *testing.T) {
if !cmp.Equal(result, want) {
t.Errorf("Search.Users returned %+v, want %+v", result, want)
}
const methodName = "Users"
testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
got, resp, err := client.Search.Users(ctx, "blah", opts)
if got != nil {
t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
}
return resp, err
})
}

func TestSearchService_Users_coverage(t *testing.T) {
Expand Down Expand Up @@ -469,6 +509,14 @@ func TestSearchService_Code(t *testing.T) {
if !cmp.Equal(result, want) {
t.Errorf("Search.Code returned %+v, want %+v", result, want)
}
const methodName = "Code"
testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
got, resp, err := client.Search.Code(ctx, "blah", opts)
if got != nil {
t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
}
return resp, err
})
}

func TestSearchService_Code_coverage(t *testing.T) {
Expand Down Expand Up @@ -583,6 +631,14 @@ func TestSearchService_Labels(t *testing.T) {
if !cmp.Equal(result, want) {
t.Errorf("Search.Labels returned %+v, want %+v", result, want)
}
const methodName = "Labels"
testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
got, resp, err := client.Search.Labels(ctx, 1234, "blah", opts)
if got != nil {
t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
}
return resp, err
})
}

func TestSearchService_Labels_coverage(t *testing.T) {
Expand Down
10 changes: 7 additions & 3 deletions scrape/apps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,22 @@ func Test_CreateApp(t *testing.T) {
t.Parallel()
client, mux := setup(t)

mux.HandleFunc("/apps/settings/new", func(w http.ResponseWriter, _ *http.Request) {
mux.HandleFunc("/settings/apps/new", func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusCreated)
})

if _, err := client.CreateApp(&AppManifest{
resp, err := client.CreateApp(&AppManifest{
URL: github.Ptr("https://example.com"),
HookAttributes: map[string]string{
"url": "https://example.com/hook",
},
}, ""); err != nil {
}, "")
if err != nil {
t.Fatalf("CreateApp: %v", err)
}
if got, want := resp.StatusCode, http.StatusCreated; got != want {
t.Errorf("CreateApp returned status code %v, want %v", got, want)
}
}

func Test_CreateAppWithOrg(t *testing.T) {
Expand Down
Loading