1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-03-17 20:47:50 +02:00

chore: enabling -race -failfast and -coverpkg (#576)

* chore: enabling -race -failfast and -coverpkg

* fix: race condition in tests
This commit is contained in:
Carlos Alexandro Becker 2018-02-24 17:31:07 -03:00 committed by GitHub
parent e999e34d96
commit 2bb509f5a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -7,7 +7,6 @@ setup:
go get -u golang.org/x/tools/cmd/stringer
go get -u github.com/alecthomas/gometalinter
go get -u github.com/golang/dep/cmd/dep
go get -u github.com/pierrre/gotestcover
go get -u golang.org/x/tools/cmd/cover
go get -u github.com/caarlos0/static/cmd/static-docs
go get -u github.com/caarlos0/bandep
@ -23,7 +22,7 @@ check:
# Run all the tests
test:
gotestcover $(TEST_OPTIONS) -covermode=atomic -coverprofile=coverage.txt $(SOURCE_FILES) -run $(TEST_PATTERN) -timeout=2m
go test $(TEST_OPTIONS) -failfast -race -coverpkg=./... -covermode=atomic -coverprofile=coverage.txt $(SOURCE_FILES) -run $(TEST_PATTERN) -timeout=2m
.PHONY: cover
# Run all the tests and opens the coverage report

View File

@ -6,6 +6,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
"sync"
"testing"
"github.com/goreleaser/goreleaser/config"
@ -201,6 +202,7 @@ type DummyClient struct {
CreatedRelease bool
UploadedFile bool
UploadedFileNames []string
Lock sync.Mutex
}
func (client *DummyClient) CreateRelease(ctx *context.Context, body string) (releaseID int64, err error) {
@ -216,6 +218,8 @@ func (client *DummyClient) CreateFile(ctx *context.Context, commitAuthor config.
}
func (client *DummyClient) Upload(ctx *context.Context, releaseID int64, name string, file *os.File) (err error) {
client.Lock.Lock()
defer client.Lock.Unlock()
if client.FailToUpload {
return errors.New("upload failed")
}