mirror of
https://github.com/itchyny/mmv.git
synced 2025-12-26 14:14:57 +08:00
test the file contents even on failure cases
This commit is contained in:
parent
a4647e9205
commit
42b640ffe3
1 changed files with 25 additions and 4 deletions
29
mmv_test.go
29
mmv_test.go
|
|
@ -142,6 +142,10 @@ func TestRename(t *testing.T) {
|
|||
"foo": "0",
|
||||
"bar": "1",
|
||||
},
|
||||
expected: map[string]string{
|
||||
"foo": "0",
|
||||
"bar": "1",
|
||||
},
|
||||
err: &emptyPathError{},
|
||||
},
|
||||
{
|
||||
|
|
@ -154,6 +158,10 @@ func TestRename(t *testing.T) {
|
|||
"foo": "0",
|
||||
"bar": "1",
|
||||
},
|
||||
expected: map[string]string{
|
||||
"foo": "0",
|
||||
"bar": "1",
|
||||
},
|
||||
err: &emptyPathError{},
|
||||
},
|
||||
{
|
||||
|
|
@ -168,6 +176,11 @@ func TestRename(t *testing.T) {
|
|||
"bar": "1",
|
||||
"baz": "2",
|
||||
},
|
||||
expected: map[string]string{
|
||||
"foo": "0",
|
||||
"bar": "1",
|
||||
"baz": "2",
|
||||
},
|
||||
err: &sameDestinationError{"baz"},
|
||||
},
|
||||
{
|
||||
|
|
@ -196,6 +209,10 @@ func TestRename(t *testing.T) {
|
|||
"foo": "0",
|
||||
"bar": "1",
|
||||
},
|
||||
expected: map[string]string{
|
||||
"foo": "0",
|
||||
"bar": "1",
|
||||
},
|
||||
err: &sameSourceError{"foo"},
|
||||
},
|
||||
{
|
||||
|
|
@ -208,6 +225,10 @@ func TestRename(t *testing.T) {
|
|||
"foo": "0",
|
||||
"bar": "1",
|
||||
},
|
||||
expected: map[string]string{
|
||||
"foo": "0",
|
||||
"bar": "1",
|
||||
},
|
||||
err: &sameDestinationError{"baz"},
|
||||
},
|
||||
{
|
||||
|
|
@ -262,13 +283,13 @@ func TestRename(t *testing.T) {
|
|||
require.NoError(t, setupFiles(tc.contents))
|
||||
rs, _ := buildRenames(clone(tc.files))
|
||||
assert.Equal(t, tc.count, len(rs))
|
||||
got := Rename(tc.files)
|
||||
err = Rename(tc.files)
|
||||
if tc.err == nil {
|
||||
require.NoError(t, got)
|
||||
assert.Equal(t, tc.expected, fileContents("."))
|
||||
assert.NoError(t, err)
|
||||
} else {
|
||||
assert.Equal(t, tc.err, got)
|
||||
assert.Equal(t, tc.err, err)
|
||||
}
|
||||
assert.Equal(t, tc.expected, fileContents("."))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue