diff --git a/go.mod b/go.mod index dd974a3..1cb3130 100644 --- a/go.mod +++ b/go.mod @@ -5,5 +5,4 @@ go 1.13 require ( github.com/mattn/getwild v0.0.1 github.com/mattn/go-tty v0.0.3 - github.com/stretchr/testify v1.4.0 ) diff --git a/go.sum b/go.sum index 3da3b9e..dec2c94 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,3 @@ -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/mattn/getwild v0.0.1 h1:+Nlzxt7fonj2MtO9y/rg5hxOnM3H6tuTqeD38W25jfo= github.com/mattn/getwild v0.0.1/go.mod h1:AG+GKQydHp7iLJn+VV+D7y8LeYs5bQ0Xz4fmKd5o1Sg= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= @@ -9,17 +7,8 @@ github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcME github.com/mattn/go-runewidth v0.0.6/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-tty v0.0.3 h1:5OfyWorkyO7xP52Mq7tB36ajHDG5OHrmBGIS/DtakQI= github.com/mattn/go-tty v0.0.3/go.mod h1:ihxohKRERHTVzN+aSVRwACLCeqIoZAWpoICkkvrWyR0= -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/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e h1:N7DeIrjYszNmSW409R3frPPwglRwMkXSBzwVbkOjLLA= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/mmv_test.go b/mmv_test.go index 2d8e270..477a2be 100644 --- a/mmv_test.go +++ b/mmv_test.go @@ -4,10 +4,9 @@ import ( "io/ioutil" "os" "path/filepath" + "reflect" + "strings" "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func TestRename(t *testing.T) { @@ -301,19 +300,31 @@ func TestRename(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { dir, err := ioutil.TempDir("", "mmv-") + if err != nil { + t.Fatalf("ioutil.TempDir returned an error: %s", err) + } defer os.RemoveAll(dir) - require.NoError(t, os.Chdir(dir)) - require.NoError(t, err) - require.NoError(t, setupFiles(tc.contents)) + if err := os.Chdir(dir); err != nil { + t.Fatalf("os.Chdir returned an error: %s", err) + } + if err := setupFiles(tc.contents); err != nil { + t.Fatalf("setupFiles returned an error: %s", err) + } rs, _ := buildRenames(clone(tc.files)) - assert.Equal(t, tc.count, len(rs)) + if got := len(rs); got != tc.count { + t.Errorf("expected: %d, got: %d", tc.count, got) + } err = Rename(tc.files) if tc.err == "" { - assert.NoError(t, err) - } else { - assert.Contains(t, err.Error(), tc.err) + if err != nil { + t.Errorf("Rename returned an error: %s", err) + } + } else if !strings.Contains(err.Error(), tc.err) { + t.Errorf("error should contain: %s, got: %s", tc.err, err) + } + if got := fileContents("."); !reflect.DeepEqual(got, tc.expected) { + t.Errorf("expected: %v, got: %v", tc.expected, got) } - assert.Equal(t, tc.expected, fileContents(".")) }) } }