Reduce duplicate code in test for fomatNode

This commit is contained in:
Michael Eischer 2023-06-08 19:16:16 +02:00
parent 5f153109ba
commit 6ebf2dd235
1 changed files with 19 additions and 30 deletions

View File

@ -9,6 +9,16 @@ import (
) )
func TestFormatNode(t *testing.T) { func TestFormatNode(t *testing.T) {
testPath := "/test/path"
node := restic.Node{
Name: "baz",
Type: "file",
Size: 14680064,
UID: 1000,
GID: 2000,
ModTime: time.Date(2020, 1, 2, 3, 4, 5, 0, time.UTC),
}
for _, c := range []struct { for _, c := range []struct {
path string path string
restic.Node restic.Node
@ -17,46 +27,25 @@ func TestFormatNode(t *testing.T) {
expect string expect string
}{ }{
{ {
path: "/test/path", path: testPath,
Node: restic.Node{ Node: node,
Name: "baz",
Type: "file",
Size: 14680064,
UID: 1000,
GID: 2000,
ModTime: time.Date(2020, 1, 2, 3, 4, 5, 0, time.UTC),
},
long: false, long: false,
human: false, human: false,
expect: "/test/path", expect: testPath,
}, },
{ {
path: "/test/path", path: testPath,
Node: restic.Node{ Node: node,
Name: "baz",
Type: "file",
Size: 14680064,
UID: 1000,
GID: 2000,
ModTime: time.Date(2020, 1, 2, 3, 4, 5, 0, time.UTC),
},
long: true, long: true,
human: false, human: false,
expect: "---------- 1000 2000 14680064 2020-01-01 22:04:05 /test/path", expect: "---------- 1000 2000 14680064 2020-01-01 22:04:05 " + testPath,
}, },
{ {
path: "/test/path", path: testPath,
Node: restic.Node{ Node: node,
Name: "baz",
Type: "file",
Size: 14680064,
UID: 1000,
GID: 2000,
ModTime: time.Date(2020, 1, 2, 3, 4, 5, 0, time.UTC),
},
long: true, long: true,
human: true, human: true,
expect: "---------- 1000 2000 14.000 MiB 2020-01-01 22:04:05 /test/path", expect: "---------- 1000 2000 14.000 MiB 2020-01-01 22:04:05 " + testPath,
}, },
} { } {
r := formatNode(c.path, &c.Node, c.long, c.human) r := formatNode(c.path, &c.Node, c.long, c.human)