Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #9: Lint action is failing #10

Merged
merged 3 commits into from
Mar 8, 2024
Merged
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: 1 addition & 1 deletion .github/workflows/quality-and-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Install gotestsum
run: make install-gotestsum
- name: Install revive
run: go get -u github.com/mgechev/revive
run: go install github.com/mgechev/revive@latest
- name: go mod tidy
run: go mod tidy
- name: go mod vendor
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ analyze: lint vet test ## Run lint, vet, and test

.PHONY: lint
lint: ## Lint the code
@! revive -config .revive.toml ./... | grep -v vendor
@ revive -config .revive.toml ./... | grep -v vendor

.PHONY: test
test: unit-test ## Run the test suite(s).
Expand Down
12 changes: 6 additions & 6 deletions slack/response_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,38 +57,38 @@ func TestUnit_ReadStatus(t *testing.T) {
},
},
},
setupBaseClient: func(t *testing.T, expectedErr glitch.DataError) client.BaseClient {
setupBaseClient: func(_ *testing.T, expectedErr glitch.DataError) client.BaseClient {
c := clientmock.NewMockBaseClient(ctrl)
c.EXPECT().MakeRequest(gomock.Any(), http.MethodGet, "test-slug", nil, gomock.Any(), nil).Return(http.StatusOK, []byte(sampleActiveResp), expectedErr)
return c
},
validate: func(t *testing.T, expectedResp, actualResp status.Details, expectedErr, actualErr glitch.DataError) {
validate: func(t *testing.T, expectedResp, actualResp status.Details, _, actualErr glitch.DataError) {
require.Equal(t, expectedResp, actualResp)
require.NoError(t, actualErr)
},
},
"exceptional path- unable to make client request": {
expectedResp: Response{},
expectedErr: glitch.NewDataError(nil, "test-err-code", "test-err"),
setupBaseClient: func(t *testing.T, expectedErr glitch.DataError) client.BaseClient {
setupBaseClient: func(_ *testing.T, expectedErr glitch.DataError) client.BaseClient {
c := clientmock.NewMockBaseClient(ctrl)
c.EXPECT().MakeRequest(gomock.Any(), http.MethodGet, "test-slug", nil, gomock.Any(), nil).Return(http.StatusInternalServerError, nil, expectedErr)
return c
},
validate: func(t *testing.T, expectedResp, actualResp status.Details, expectedErr, actualErr glitch.DataError) {
validate: func(t *testing.T, expectedResp, actualResp status.Details, _, actualErr glitch.DataError) {
require.Equal(t, expectedResp, actualResp)
require.Error(t, actualErr)
require.Equal(t, status.ErrorUnableToMakeClientRequest, actualErr.Code())
},
},
"exceptional path- unable to parse response": {
expectedResp: Response{},
setupBaseClient: func(t *testing.T, expectedErr glitch.DataError) client.BaseClient {
setupBaseClient: func(_ *testing.T, expectedErr glitch.DataError) client.BaseClient {
c := clientmock.NewMockBaseClient(ctrl)
c.EXPECT().MakeRequest(gomock.Any(), http.MethodGet, "test-slug", nil, gomock.Any(), nil).Return(http.StatusOK, []byte(`{bad: ^JSON`), expectedErr)
return c
},
validate: func(t *testing.T, expectedResp, actualResp status.Details, expectedErr, actualErr glitch.DataError) {
validate: func(t *testing.T, expectedResp, actualResp status.Details, _, actualErr glitch.DataError) {
require.Equal(t, expectedResp, actualResp)
require.Error(t, actualErr)
require.Equal(t, status.ErrorUnableToParseClientResponse, actualErr.Code())
Expand Down
12 changes: 6 additions & 6 deletions statuspageio/response_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,38 +41,38 @@ func TestUnit_ReadStatus(t *testing.T) {
UpdatedAt: sampleOKTime,
},
},
setupBaseClient: func(t *testing.T, expectedErr glitch.DataError) client.BaseClient {
setupBaseClient: func(_ *testing.T, expectedErr glitch.DataError) client.BaseClient {
c := clientmock.NewMockBaseClient(ctrl)
c.EXPECT().MakeRequest(gomock.Any(), http.MethodGet, "test-slug", nil, gomock.Any(), nil).Return(http.StatusOK, []byte(sampleOKResp), expectedErr)
return c
},
validate: func(t *testing.T, expectedResp, actualResp status.Details, expectedErr, actualErr glitch.DataError) {
validate: func(t *testing.T, expectedResp, actualResp status.Details, _, actualErr glitch.DataError) {
require.Equal(t, expectedResp, actualResp)
require.NoError(t, actualErr)
},
},
"exceptional path- unable to make client request": {
expectedResp: Response{},
expectedErr: glitch.NewDataError(nil, "test-err-code", "test-err"),
setupBaseClient: func(t *testing.T, expectedErr glitch.DataError) client.BaseClient {
setupBaseClient: func(_ *testing.T, expectedErr glitch.DataError) client.BaseClient {
c := clientmock.NewMockBaseClient(ctrl)
c.EXPECT().MakeRequest(gomock.Any(), http.MethodGet, "test-slug", nil, gomock.Any(), nil).Return(http.StatusInternalServerError, nil, expectedErr)
return c
},
validate: func(t *testing.T, expectedResp, actualResp status.Details, expectedErr, actualErr glitch.DataError) {
validate: func(t *testing.T, expectedResp, actualResp status.Details, _, actualErr glitch.DataError) {
require.Equal(t, expectedResp, actualResp)
require.Error(t, actualErr)
require.Equal(t, status.ErrorUnableToMakeClientRequest, actualErr.Code())
},
},
"exceptional path- unable to parse response": {
expectedResp: Response{},
setupBaseClient: func(t *testing.T, expectedErr glitch.DataError) client.BaseClient {
setupBaseClient: func(_ *testing.T, expectedErr glitch.DataError) client.BaseClient {
c := clientmock.NewMockBaseClient(ctrl)
c.EXPECT().MakeRequest(gomock.Any(), http.MethodGet, "test-slug", nil, gomock.Any(), nil).Return(http.StatusOK, []byte(`{bad: ^JSON`), expectedErr)
return c
},
validate: func(t *testing.T, expectedResp, actualResp status.Details, expectedErr, actualErr glitch.DataError) {
validate: func(t *testing.T, expectedResp, actualResp status.Details, _, actualErr glitch.DataError) {
require.Equal(t, expectedResp, actualResp)
require.Error(t, actualErr)
require.Equal(t, status.ErrorUnableToParseClientResponse, actualErr.Code())
Expand Down
6 changes: 4 additions & 2 deletions whatsup/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ func NewStatusPageClient() StatusPageClient {
// StatuspageIoService handles fetching statuspage.io style status pages
func (spc *statusPageClient) StatuspageIoService(serviceName, pageURL string) (status.Details, glitch.DataError) {
u, err := url.Parse(pageURL)
sf := func(serviceName string, useTLS bool) (url.URL, error) {
// No use for service name or use TLS flag here.
sf := func(_ string, _ bool) (url.URL, error) {
return *u, err
}
c := client.NewBaseClient(sf, serviceName, true, 10*time.Second, nil)
Expand All @@ -43,7 +44,8 @@ func (spc *statusPageClient) StatuspageIoService(serviceName, pageURL string) (s
func (spc *statusPageClient) Slack() (status.Details, glitch.DataError) {
sn := slack.ServiceType
u, err := url.Parse("https://status.slack.com/api/v2.0.0/current")
sf := func(serviceName string, useTLS bool) (url.URL, error) {
// No use for service name or use TLS flag here.
sf := func(_ string, _ bool) (url.URL, error) {
return *u, err
}
c := client.NewBaseClient(sf, sn, true, 10*time.Second, nil)
Expand Down
Loading