Add race detection and coverage to test

This commit is contained in:
Lena Fuhrimann 2018-04-14 01:24:20 +02:00
parent 45d34233a5
commit aacce5cfdf
7 changed files with 29 additions and 17 deletions

View file

@ -1,10 +1,11 @@
language: go
before_install:
- curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
- curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
install:
- dep ensure
- dep ensure
script:
- go test ./... -race
- make test
- make

17
Gopkg.lock generated
View file

@ -16,8 +16,8 @@
[[projects]]
name = "github.com/go-ini/ini"
packages = ["."]
revision = "ace140f73450505f33e8b8418216792275ae82a7"
version = "v1.35.0"
revision = "6529cf7c58879c08d927016dde4477f18a0634cb"
version = "v1.36.0"
[[projects]]
name = "github.com/gorilla/context"
@ -43,13 +43,12 @@
".",
"pkg/credentials",
"pkg/encrypt",
"pkg/policy",
"pkg/s3signer",
"pkg/s3utils",
"pkg/set"
]
revision = "66252c2a3c15f7b90cc8493d497a04ac3b6e3606"
version = "5.0.0"
revision = "3d2d02921f0510e9d1f66ef77a265b8dddd36992"
version = "6.0.0"
[[projects]]
branch = "master"
@ -89,7 +88,7 @@
"blake2b",
"ssh/terminal"
]
revision = "d6449816ce06963d9d136eee5a56fca5b0616e7e"
revision = "e73bf333ef8920dbb52ad18d4bd38ad9d9bc76d7"
[[projects]]
branch = "master"
@ -98,7 +97,7 @@
"idna",
"lex/httplex"
]
revision = "61147c48b25b599e5b561d2e9c4f3e1ef489ca41"
revision = "5f9ae10d9af5b1c89ae6904293b14b064d4ada23"
[[projects]]
branch = "master"
@ -107,7 +106,7 @@
"unix",
"windows"
]
revision = "f6f352972f061230a99fbf49d1eb8073ebdb36cb"
revision = "79b0c6888797020a994db17c8510466c72fe75d9"
[[projects]]
name = "golang.org/x/text"
@ -133,6 +132,6 @@
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
inputs-digest = "2eb6d0e6d0142a6a38557c70a42069775e66ccbe7aea1620c03752808dcacb1a"
inputs-digest = "4c4a5f2d2bc9b8772e808cad8a6ba572ade767284ff64d92f8b44b4a18b6d64f"
solver-name = "gps-cdcl"
solver-version = 1

View file

@ -35,7 +35,7 @@
[[constraint]]
name = "github.com/minio/minio-go"
version = "5.0.0"
version = "6.0.0"
[[constraint]]
name = "github.com/pkg/errors"

View file

@ -1,8 +1,11 @@
all:
go build ./cmd/s3manager
lint:
gometalinter ./... --vendor --tests
test:
go test ./...
go test ./... -race -cover
build-docker:
docker build . -f build/docker/Dockerfile -t s3manager

View file

@ -117,7 +117,12 @@ func TestBucketViewHandler(t *testing.T) {
url := fmt.Sprintf("%s/buckets/%s", ts.URL, tc.bucketName)
resp, err := http.Get(url)
assert.NoError(err, tcID)
defer resp.Body.Close()
defer func() {
err = resp.Body.Close()
if err != nil {
t.FailNow()
}
}()
body, err := ioutil.ReadAll(resp.Body)
assert.NoError(err, tcID)

View file

@ -14,7 +14,6 @@ const (
errDecodingBody = "error decoding body JSON"
errEncodingJSON = "error encoding JSON"
errExecutingTemplate = "error executing template"
errGettingWD = "error getting working directory"
errParsingForm = "error parsing form"
errParsingTemplates = "error parsing template files"
)

View file

@ -48,7 +48,12 @@ func TestGetObjectHandler(t *testing.T) {
url := fmt.Sprintf("%s/buckets/%s/objects/%s", ts.URL, tc.bucketName, tc.objectName)
resp, err := http.Get(url)
assert.NoError(err, tcID)
defer resp.Body.Close()
defer func() {
err = resp.Body.Close()
if err != nil {
t.FailNow()
}
}()
body, err := ioutil.ReadAll(resp.Body)
assert.NoError(err, tcID)