Skip to content

Commit

Permalink
Upgrade to go modules (#54)
Browse files Browse the repository at this point in the history
* Use https://github.com/marwan-at-work/mod to upgrade

* Remove go dep

* Enable modules in CI

* Make GO111MODULE a global env variable

* Fix shadowed env variable

* Switch to golangci-lint

* Fix GO111MODULE value
  • Loading branch information
bradleyjkemp authored Jan 19, 2019
1 parent a2f15f7 commit 4ebc4e8
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 92 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ notifications:
env:
global:
- MAKEFLAGS=" -j 2"
- GO111MODULE=on
48 changes: 0 additions & 48 deletions Gopkg.lock

This file was deleted.

30 changes: 0 additions & 30 deletions Gopkg.toml

This file was deleted.

9 changes: 2 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,14 @@ install: get_dependencies install_linters
.PHONY: get_dependencies
get_dependencies:
go get github.com/mattn/goveralls
go get github.com/golang/dep/cmd/dep
$(GOPATH)/bin/dep ensure

.PHONY: install_linters
install_linters:
go get -u github.com/alecthomas/gometalinter
$(GOPATH)/bin/gometalinter --install
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(GOPATH)/bin v1.12.5

.PHONY: lint
lint:
$(GOPATH)/bin/gometalinter \
--disable=gosec \
--vendor ./...
$(GOPATH)/bin/golangci-lint run

.PHONY: test
test: lint
Expand Down
6 changes: 3 additions & 3 deletions examples/advanced_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strings"
"testing"

"github.com/bradleyjkemp/cupaloy"
"github.com/bradleyjkemp/cupaloy/v2"
"github.com/stretchr/testify/mock"
)

Expand Down Expand Up @@ -48,7 +48,7 @@ func TestConfig(t *testing.T) {
// If a snapshot is updated then this returns an error
// This is to prevent you accidentally updating your snapshots in CI
func TestUpdate(t *testing.T) {
snapshotter := cupaloy.New(cupaloy.EnvVariableName("GOPATH"))
snapshotter := cupaloy.New(cupaloy.EnvVariableName("HOME"))

err := snapshotter.Snapshot("Hello world")
if err != nil {
Expand Down Expand Up @@ -176,7 +176,7 @@ func TestGlobalCreateNewAutomatically(t *testing.T) {
}

func TestFailOnUpdate(t *testing.T) {
snapshotter := cupaloy.New(cupaloy.EnvVariableName("GOPATH"), cupaloy.FailOnUpdate(false))
snapshotter := cupaloy.New(cupaloy.EnvVariableName("HOME"), cupaloy.FailOnUpdate(false))

err := snapshotter.Snapshot("Hello new world")
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion examples/basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package examples
import (
"testing"

"github.com/bradleyjkemp/cupaloy"
"github.com/bradleyjkemp/cupaloy/v2"
)

func TestString(t *testing.T) {
Expand Down
8 changes: 8 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module github.com/bradleyjkemp/cupaloy/v2

require (
github.com/davecgh/go-spew v1.1.1
github.com/pmezard/go-difflib v1.0.0
github.com/stretchr/objx v0.1.1 // indirect
github.com/stretchr/testify v1.2.2
)
8 changes: 8 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
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.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
6 changes: 3 additions & 3 deletions util.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ func takeV1Snapshot(i ...interface{}) string {
func takeSnapshot(i ...interface{}) string {
snapshot := &bytes.Buffer{}
for _, v := range i {
switch v.(type) {
switch vt := v.(type) {
case string:
snapshot.WriteString(v.(string))
snapshot.WriteString(vt)
snapshot.WriteString("\n")
case []byte:
snapshot.Write(v.([]byte))
snapshot.Write(vt)
snapshot.WriteString("\n")
default:
spewConfig.Fdump(snapshot, v)
Expand Down

0 comments on commit 4ebc4e8

Please sign in to comment.