Skip to content

Commit

Permalink
Reactivate forbidigo, gci, ifshort, nlreturn, paralleltest and thelpe…
Browse files Browse the repository at this point in the history
…r linters (#3)
  • Loading branch information
aaronsky authored Apr 20, 2021
1 parent 580a050 commit e4831fb
Show file tree
Hide file tree
Showing 81 changed files with 702 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,5 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@master
with:
version: v1.37
version: v1.39
skip-go-installation: true
9 changes: 3 additions & 6 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,11 @@ linters:
disable:
- cyclop
- exhaustivestruct
- forbidigo
- funlen
- gci
- gofumpt
- ifshort
- interfacer
- lll
- nlreturn
- paralleltest
- maligned
- scopelint
- testpackage
- thelper
- wrapcheck
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ The authenticated client created here will automatically regenerate the token if

### Rate Limiting

Apple imposes a rate limit on all API clients. The returned `Response.Rate` value contains the rate limit information from the most recent API call. If the API produces a rate limit error, it will be identifiable as an `ErrorResponse` with an error code of `429`.
Apple imposes a rate limit on all API clients. The returned `Response.Rate` value contains the rate limit information from the most recent API call. If the API produces a rate limit error, it will be identifiable as an `ErrorResponse` with an error code of `429`.

Learn more about rate limiting at <https://developer.apple.com/documentation/appstoreconnectapi/identifying_rate_limits>.

### Pagination

All requests for resource collections (apps, builds, beta groups, etc.) support pagination. Responses for paginated resources will contain a `Links` property of type `PagedDocumentLinks`, with `Reference` URLs for first, next, and self. A `Reference` can have its cursor extracted with the `Cursor()` method, and that can be passed to a query param using its `Cursor` field. You can also find more information about the per-page limit and total count of resources in the response's `Meta` field of type `PagingInformation`.
All requests for resource collections (apps, builds, beta groups, etc.) support pagination. Responses for paginated resources will contain a `Links` property of type `PagedDocumentLinks`, with `Reference` URLs for first, next, and self. A `Reference` can have its cursor extracted with the `Cursor()` method, and that can be passed to a query param using its `Cursor` field. You can also find more information about the per-page limit and total count of resources in the response's `Meta` field of type `PagingInformation`.

```go
auth, _ = asc.NewTokenConfig(keyID, issuerID, expiryDuration, privateKey)
Expand All @@ -90,7 +90,7 @@ for {
if err != nil {
return err
}
allApps = append(allApps, apps.Data...)
allApps = append(allApps, apps.Data...)
if apps.Links.Next == nil {
break
}
Expand Down
2 changes: 2 additions & 0 deletions asc/apps_metadata_age_ratings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import (
)

func TestUpdateAgeRatingDeclaration(t *testing.T) {
t.Parallel()

testEndpointWithResponse(t, "{}", &AgeRatingDeclarationResponse{}, func(ctx context.Context, client *Client) (interface{}, *Response, error) {
return client.Apps.UpdateAgeRatingDeclaration(ctx, "10", &AgeRatingDeclarationUpdateRequestAttributes{})
})
Expand Down
22 changes: 22 additions & 0 deletions asc/apps_metadata_categories_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,32 @@ import (
)

func TestListAppCategories(t *testing.T) {
t.Parallel()

testEndpointWithResponse(t, "{}", &AppCategoriesResponse{}, func(ctx context.Context, client *Client) (interface{}, *Response, error) {
return client.Apps.ListAppCategories(ctx, &ListAppCategoriesQuery{})
})
}

func TestListSubcategoriesForAppCategory(t *testing.T) {
t.Parallel()

testEndpointWithResponse(t, "{}", &AppCategoriesResponse{}, func(ctx context.Context, client *Client) (interface{}, *Response, error) {
return client.Apps.ListSubcategoriesForAppCategory(ctx, "10", &ListSubcategoriesForAppCategoryQuery{})
})
}

func TestGetAppCategory(t *testing.T) {
t.Parallel()

testEndpointWithResponse(t, "{}", &AppCategoryResponse{}, func(ctx context.Context, client *Client) (interface{}, *Response, error) {
return client.Apps.GetAppCategory(ctx, "10", &GetAppCategoryQuery{})
})
}

func TestGetAppCategoryIncludeds(t *testing.T) {
t.Parallel()

testEndpointCustomBehavior(`{"included":[{"type":"appCategories"},{"type":"appInfos"}]}`, func(ctx context.Context, client *Client) {
category, _, err := client.Apps.GetAppCategory(ctx, "10", &GetAppCategoryQuery{})
assert.NoError(t, err)
Expand All @@ -57,42 +65,56 @@ func TestGetAppCategoryIncludeds(t *testing.T) {
}

func TestGetParentCategoryForAppCategory(t *testing.T) {
t.Parallel()

testEndpointWithResponse(t, "{}", &AppCategoryResponse{}, func(ctx context.Context, client *Client) (interface{}, *Response, error) {
return client.Apps.GetParentCategoryForAppCategory(ctx, "10", &GetAppCategoryForAppInfoQuery{})
})
}

func TestGetPrimaryCategoryForAppInfo(t *testing.T) {
t.Parallel()

testEndpointWithResponse(t, "{}", &AppCategoryResponse{}, func(ctx context.Context, client *Client) (interface{}, *Response, error) {
return client.Apps.GetPrimaryCategoryForAppInfo(ctx, "10", &GetAppCategoryForAppInfoQuery{})
})
}

func TestGetSecondaryCategoryForAppInfo(t *testing.T) {
t.Parallel()

testEndpointWithResponse(t, "{}", &AppCategoryResponse{}, func(ctx context.Context, client *Client) (interface{}, *Response, error) {
return client.Apps.GetSecondaryCategoryForAppInfo(ctx, "10", &GetAppCategoryForAppInfoQuery{})
})
}

func TestGetPrimarySubcategoryOneForAppInfo(t *testing.T) {
t.Parallel()

testEndpointWithResponse(t, "{}", &AppCategoryResponse{}, func(ctx context.Context, client *Client) (interface{}, *Response, error) {
return client.Apps.GetPrimarySubcategoryOneForAppInfo(ctx, "10", &GetAppCategoryForAppInfoQuery{})
})
}

func TestGetPrimarySubcategoryTwoForAppInfo(t *testing.T) {
t.Parallel()

testEndpointWithResponse(t, "{}", &AppCategoryResponse{}, func(ctx context.Context, client *Client) (interface{}, *Response, error) {
return client.Apps.GetPrimarySubcategoryTwoForAppInfo(ctx, "10", &GetAppCategoryForAppInfoQuery{})
})
}

func TestGetSecondarySubcategoryOneForAppInfo(t *testing.T) {
t.Parallel()

testEndpointWithResponse(t, "{}", &AppCategoryResponse{}, func(ctx context.Context, client *Client) (interface{}, *Response, error) {
return client.Apps.GetSecondarySubcategoryOneForAppInfo(ctx, "10", &GetAppCategoryForAppInfoQuery{})
})
}

func TestGetSecondarySubcategoryTwoForAppInfo(t *testing.T) {
t.Parallel()

testEndpointWithResponse(t, "{}", &AppCategoryResponse{}, func(ctx context.Context, client *Client) (interface{}, *Response, error) {
return client.Apps.GetSecondarySubcategoryTwoForAppInfo(ctx, "10", &GetAppCategoryForAppInfoQuery{})
})
Expand Down
1 change: 1 addition & 0 deletions asc/apps_metadata_eula.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ func (s *AppsService) UpdateEULA(ctx context.Context, id string, agreementText *
// https://developer.apple.com/documentation/appstoreconnectapi/delete_an_end_user_license_agreement
func (s *AppsService) DeleteEULA(ctx context.Context, id string) (*Response, error) {
url := fmt.Sprintf("endUserLicenseAgreements/%s", id)

return s.client.delete(ctx, url, nil)
}

Expand Down
10 changes: 10 additions & 0 deletions asc/apps_metadata_eula_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,30 +26,40 @@ import (
)

func TestCreateEULA(t *testing.T) {
t.Parallel()

testEndpointWithResponse(t, "{}", &EndUserLicenseAgreementResponse{}, func(ctx context.Context, client *Client) (interface{}, *Response, error) {
return client.Apps.CreateEULA(ctx, "", "", []string{"10"})
})
}

func TestUpdateEULA(t *testing.T) {
t.Parallel()

testEndpointWithResponse(t, "{}", &EndUserLicenseAgreementResponse{}, func(ctx context.Context, client *Client) (interface{}, *Response, error) {
return client.Apps.UpdateEULA(ctx, "10", String(""), []string{"10"})
})
}

func TestDeleteEULA(t *testing.T) {
t.Parallel()

testEndpointWithNoContent(t, func(ctx context.Context, client *Client) (*Response, error) {
return client.Apps.DeleteEULA(ctx, "10")
})
}

func TestGetEULA(t *testing.T) {
t.Parallel()

testEndpointWithResponse(t, "{}", &EndUserLicenseAgreementResponse{}, func(ctx context.Context, client *Client) (interface{}, *Response, error) {
return client.Apps.GetEULA(ctx, "10", &GetEULAQuery{})
})
}

func TestGetEULAForApp(t *testing.T) {
t.Parallel()

testEndpointWithResponse(t, "{}", &EndUserLicenseAgreementResponse{}, func(ctx context.Context, client *Client) (interface{}, *Response, error) {
return client.Apps.GetEULAForApp(ctx, "10", &GetEULAForAppQuery{})
})
Expand Down
12 changes: 12 additions & 0 deletions asc/apps_metadata_game_center_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,36 +26,48 @@ import (
)

func TestListGameCenterEnabledVersionsForApp(t *testing.T) {
t.Parallel()

testEndpointWithResponse(t, "{}", &GameCenterEnabledVersionsResponse{}, func(ctx context.Context, client *Client) (interface{}, *Response, error) {
return client.Apps.ListGameCenterEnabledVersionsForApp(ctx, "10", &ListGameCenterEnabledVersionsForAppQuery{})
})
}

func TestListCompatibleVersionsForGameCenterEnabledVersion(t *testing.T) {
t.Parallel()

testEndpointWithResponse(t, "{}", &GameCenterEnabledVersionsResponse{}, func(ctx context.Context, client *Client) (interface{}, *Response, error) {
return client.Apps.ListCompatibleVersionsForGameCenterEnabledVersion(ctx, "10", &ListCompatibleVersionsForGameCenterEnabledVersionQuery{})
})
}

func TestListCompatibleVersionIDsForGameCenterEnabledVersion(t *testing.T) {
t.Parallel()

testEndpointWithResponse(t, "{}", &GameCenterEnabledVersionCompatibleVersionsLinkagesResponse{}, func(ctx context.Context, client *Client) (interface{}, *Response, error) {
return client.Apps.ListCompatibleVersionIDsForGameCenterEnabledVersion(ctx, "10", &ListCompatibleVersionIDsForGameCenterEnabledVersionQuery{})
})
}

func TestCreateCompatibleVersionsForGameCenterEnabledVersion(t *testing.T) {
t.Parallel()

testEndpointWithNoContent(t, func(ctx context.Context, client *Client) (*Response, error) {
return client.Apps.CreateCompatibleVersionsForGameCenterEnabledVersion(ctx, "10", []string{"10"})
})
}

func TestUpdateCompatibleVersionsForGameCenterEnabledVersion(t *testing.T) {
t.Parallel()

testEndpointWithNoContent(t, func(ctx context.Context, client *Client) (*Response, error) {
return client.Apps.UpdateCompatibleVersionsForGameCenterEnabledVersion(ctx, "10", []string{"10"})
})
}

func TestRemoveCompatibleVersionsForGameCenterEnabledVersion(t *testing.T) {
t.Parallel()

testEndpointWithNoContent(t, func(ctx context.Context, client *Client) (*Response, error) {
return client.Apps.RemoveCompatibleVersionsForGameCenterEnabledVersion(ctx, "10", []string{"10"})
})
Expand Down
1 change: 1 addition & 0 deletions asc/apps_metadata_info_localizations.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,5 +202,6 @@ func (s *AppsService) UpdateAppInfoLocalization(ctx context.Context, id string,
// https://developer.apple.com/documentation/appstoreconnectapi/delete_an_app_info_localization
func (s *AppsService) DeleteAppInfoLocalization(ctx context.Context, id string) (*Response, error) {
url := fmt.Sprintf("appInfoLocalizations/%s", id)

return s.client.delete(ctx, url, nil)
}
10 changes: 10 additions & 0 deletions asc/apps_metadata_info_localizations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,30 +26,40 @@ import (
)

func TestListAppInfoLocalizationsForAppInfo(t *testing.T) {
t.Parallel()

testEndpointWithResponse(t, "{}", &AppInfoLocalizationsResponse{}, func(ctx context.Context, client *Client) (interface{}, *Response, error) {
return client.Apps.ListAppInfoLocalizationsForAppInfo(ctx, "10", &ListAppInfoLocalizationsForAppInfoQuery{})
})
}

func TestGetAppInfoLocalization(t *testing.T) {
t.Parallel()

testEndpointWithResponse(t, "{}", &AppInfoLocalizationResponse{}, func(ctx context.Context, client *Client) (interface{}, *Response, error) {
return client.Apps.GetAppInfoLocalization(ctx, "10", &GetAppInfoLocalizationQuery{})
})
}

func TestCreateAppInfoLocalization(t *testing.T) {
t.Parallel()

testEndpointWithResponse(t, "{}", &AppInfoLocalizationResponse{}, func(ctx context.Context, client *Client) (interface{}, *Response, error) {
return client.Apps.CreateAppInfoLocalization(ctx, AppInfoLocalizationCreateRequestAttributes{}, "")
})
}

func TestUpdateAppInfoLocalization(t *testing.T) {
t.Parallel()

testEndpointWithResponse(t, "{}", &AppInfoLocalizationResponse{}, func(ctx context.Context, client *Client) (interface{}, *Response, error) {
return client.Apps.UpdateAppInfoLocalization(ctx, "10", &AppInfoLocalizationUpdateRequestAttributes{})
})
}

func TestDeleteAppInfoLocalization(t *testing.T) {
t.Parallel()

testEndpointWithNoContent(t, func(ctx context.Context, client *Client) (*Response, error) {
return client.Apps.DeleteAppInfoLocalization(ctx, "10")
})
Expand Down
8 changes: 8 additions & 0 deletions asc/apps_metadata_infos_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,16 @@ import (
)

func TestGetAppInfo(t *testing.T) {
t.Parallel()

testEndpointWithResponse(t, "{}", &AppInfoResponse{}, func(ctx context.Context, client *Client) (interface{}, *Response, error) {
return client.Apps.GetAppInfo(ctx, "10", &GetAppInfoQuery{})
})
}

func TestGetAppInfoIncludeds(t *testing.T) {
t.Parallel()

testEndpointCustomBehavior(`{"included":[{"type":"appInfoLocalizations"},{"type":"appCategories"}]}`, func(ctx context.Context, client *Client) {
infos, _, err := client.Apps.GetAppInfo(ctx, "10", &GetAppInfoQuery{})
assert.NoError(t, err)
Expand All @@ -48,12 +52,16 @@ func TestGetAppInfoIncludeds(t *testing.T) {
}

func TestListAppInfosForApp(t *testing.T) {
t.Parallel()

testEndpointWithResponse(t, "{}", &AppInfosResponse{}, func(ctx context.Context, client *Client) (interface{}, *Response, error) {
return client.Apps.ListAppInfosForApp(ctx, "10", &ListAppInfosForAppQuery{})
})
}

func TestUpdateAppInfo(t *testing.T) {
t.Parallel()

testEndpointWithResponse(t, "{}", &AppInfoResponse{}, func(ctx context.Context, client *Client) (interface{}, *Response, error) {
return client.Apps.UpdateAppInfo(ctx, "10", &AppInfoUpdateRequestRelationships{})
})
Expand Down
1 change: 1 addition & 0 deletions asc/apps_metadata_preview_sets.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ func (s *AppsService) CreateAppPreviewSet(ctx context.Context, previewType Previ
// https://developer.apple.com/documentation/appstoreconnectapi/delete_an_app_preview_set
func (s *AppsService) DeleteAppPreviewSet(ctx context.Context, id string) (*Response, error) {
url := fmt.Sprintf("appPreviewSets/%s", id)

return s.client.delete(ctx, url, nil)
}

Expand Down
12 changes: 12 additions & 0 deletions asc/apps_metadata_preview_sets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,36 +26,48 @@ import (
)

func TestGetAppPreviewSet(t *testing.T) {
t.Parallel()

testEndpointWithResponse(t, "{}", &AppPreviewSetResponse{}, func(ctx context.Context, client *Client) (interface{}, *Response, error) {
return client.Apps.GetAppPreviewSet(ctx, "10", &GetAppPreviewSetQuery{})
})
}

func TestCreateAppPreviewSet(t *testing.T) {
t.Parallel()

testEndpointWithResponse(t, "{}", &AppPreviewSetResponse{}, func(ctx context.Context, client *Client) (interface{}, *Response, error) {
return client.Apps.CreateAppPreviewSet(ctx, PreviewTypeiPadPro129, "")
})
}

func TestDeleteAppPreviewSet(t *testing.T) {
t.Parallel()

testEndpointWithNoContent(t, func(ctx context.Context, client *Client) (*Response, error) {
return client.Apps.DeleteAppPreviewSet(ctx, "10")
})
}

func TestListAppPreviewsForSet(t *testing.T) {
t.Parallel()

testEndpointWithResponse(t, "{}", &AppPreviewsResponse{}, func(ctx context.Context, client *Client) (interface{}, *Response, error) {
return client.Apps.ListAppPreviewsForSet(ctx, "10", &ListAppPreviewsForSetQuery{})
})
}

func TestListAppPreviewIDsForSet(t *testing.T) {
t.Parallel()

testEndpointWithResponse(t, "{}", &AppPreviewSetAppPreviewsLinkagesResponse{}, func(ctx context.Context, client *Client) (interface{}, *Response, error) {
return client.Apps.ListAppPreviewIDsForSet(ctx, "10", &ListAppPreviewIDsForSetQuery{})
})
}

func TestReplaceAppPreviewsForSet(t *testing.T) {
t.Parallel()

testEndpointWithNoContent(t, func(ctx context.Context, client *Client) (*Response, error) {
return client.Apps.ReplaceAppPreviewsForSet(ctx, "10", []string{"10"})
})
Expand Down
1 change: 1 addition & 0 deletions asc/apps_metadata_previews.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,5 +239,6 @@ func (s *AppsService) CommitAppPreview(ctx context.Context, id string, uploaded
// https://developer.apple.com/documentation/appstoreconnectapi/delete_an_app_preview
func (s *AppsService) DeleteAppPreview(ctx context.Context, id string) (*Response, error) {
url := fmt.Sprintf("appPreviews/%s", id)

return s.client.delete(ctx, url, nil)
}
Loading

0 comments on commit e4831fb

Please sign in to comment.