Skip to content

Commit

Permalink
chore: add a small test to this repo (#7)
Browse files Browse the repository at this point in the history
* chore: add a small test to this repo

* chore: add golagci lint configuration
  • Loading branch information
ItsSudip authored Jan 15, 2024
1 parent 8e42546 commit 02c05a9
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 1 deletion.
7 changes: 6 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ on:
branches:
- main
pull_request:
types:
- opened
- reopened
- synchronize
jobs:
unit:
name: Unit
Expand All @@ -22,4 +26,5 @@ jobs:
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.txt
70 changes: 70 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
run:
timeout: 7m
go: '1.21'
skip-dirs:
- event-schema

linters:
enable:
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- typecheck
- unused
- unparam
- unconvert
- bodyclose
- decorder
- makezero
- nilnil
- nilerr
- rowserrcheck
- tenv
- wastedassign
- unparam
- misspell
- unconvert
- depguard
- unused

issues:
exclude-use-default: true
exclude-case-sensitive: false
max-issues-per-linter: 50
max-same-issues: 10
new: false
exclude-rules:
# False positive httptest.NewRecorder
- path: 'gateway/webhook/webhook_test.go'
linters:
- bodyclose

# False positive .Close behind if
- path: 'processor/transformer/transformer.go'
linters:
- bodyclose

# False positive httptest.NewRecorder
- path: 'gateway/gateway_test.go'
linters:
- bodyclose

- path: 'cmd/rudder-cli/status/status.go'
linters:
- bodyclose

linters-settings:
depguard:
rules:
main:
files:
- $all
- "!**/uuid_test.go"
deny:
- pkg: "github.com/gofrs/uuid"
desc: 'use github.com/google/uuid instead'
- pkg: "golang.org/x/exp/slices"
desc: 'use "slices" instead'

18 changes: 18 additions & 0 deletions bingads/bulk_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package bingads

import (
"reflect"
"testing"
)

func TestNewBulkService(t *testing.T) {
session := &Session{}
want := &BulkService{
Endpoint: "https://bulk.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/v13/BulkService.svc",
Session: session,
}
bulkService := NewBulkService(session)
if !reflect.DeepEqual(want, bulkService) {
t.Fatalf(`Test failed`)
}
}
1 change: 1 addition & 0 deletions bingads/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func (b *Session) sendRequest(body interface{}, endpoint, soapAction, ns string)
if err != nil {
return nil, err
}
defer response.Body.Close()

raw, err := io.ReadAll(response.Body)
if err != nil {
Expand Down

0 comments on commit 02c05a9

Please sign in to comment.