Skip to content

Commit

Permalink
test: refactor and add comprehensive tests
Browse files Browse the repository at this point in the history
BREAKING CHANGE:
* rework tests to not rely on external services
* add test run and coveralls to CI
* refactor options and allow for message-level overrides via `merge()`
* change meta format
  * Meta is now expected to be supplied as a valid JSON string
  * Meta is now properly marshalled to either a string or an object
    in the line payload depending on the IndexMeta option

Semver: major
Ref: LOG-6966,LOG-7026
  • Loading branch information
mdeltito committed Aug 25, 2020
1 parent 6b9cfa9 commit 1d69b6a
Show file tree
Hide file tree
Showing 9 changed files with 589 additions and 515 deletions.
20 changes: 18 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,24 @@ jobs:
- image: circleci/golang:1.14
steps:
- checkout
- run: go get -u golang.org/x/lint/golint
- run: golint -set_exit_status **/*.go
- run:
name: "Install test dependencies"
command: |
go get -u golang.org/x/lint/golint
go get github.com/mattn/goveralls
- run:
name: "Lint"
command: |
golint -set_exit_status **/*.go
- run:
name: "Run tests"
command: |
mkdir -p /tmp/artifacts
go test -v -coverprofile=/tmp/artifacts/profile.out -covermode=count ./logger
go tool cover -html=/tmp/artifacts/profile.out -o /tmp/artifacts/coverage.html
goveralls -coverprofile=/tmp/artifacts/profile.out -service=circleci -repotoken $COVERALLS_REPO_TOKEN
- store_artifacts:
path: /tmp/artifacts
build:
machine: true
steps:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.DS_Store
*.out
5 changes: 4 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ module github.com/logdna/logdna-go

go 1.14

require github.com/joho/godotenv v1.3.0
require (
github.com/joho/godotenv v1.3.0
github.com/stretchr/testify v1.6.1
)
11 changes: 11 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Loading

0 comments on commit 1d69b6a

Please sign in to comment.