From cad42281de18dbca418eb11bed8a2fb5efdd93f4 Mon Sep 17 00:00:00 2001 From: Mark Bates Date: Sat, 21 Sep 2019 17:11:07 -0400 Subject: [PATCH] for you both --- pkging/info_test.go | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/pkging/info_test.go b/pkging/info_test.go index bde8c0f..4fe7afa 100644 --- a/pkging/info_test.go +++ b/pkging/info_test.go @@ -8,7 +8,6 @@ import ( ) func Test_NewFileInfo(t *testing.T) { - const exp = "/public/images/mark.png" in := []string{ "/public/images/mark.png", @@ -22,6 +21,7 @@ func Test_NewFileInfo(t *testing.T) { "\\public\\images\\mark.png", } + const exp = "/public/images/mark.png" for _, n := range in { t.Run(n, func(st *testing.T) { r := require.New(st) @@ -45,3 +45,38 @@ func Test_NewFileInfo(t *testing.T) { } } + +func Test_WithName(t *testing.T) { + + f1 := &FileInfo{ + Details: Details{ + Name: "/walls/crumbling", + Size: 42, + Mode: os.FileMode(0644), + IsDir: true, + }, + } + + const exp = "/public/images/mark.png" + in := []string{ + "/public/images/mark.png", + "public/images/mark.png", + "/public\\images/mark.png", + "public/images\\mark.png", + "\\public\\images\\mark.png", + "public\\images\\mark.png", + "\\public/images\\mark.png", + "public\\images/mark.png", + "\\public\\images\\mark.png", + } + + for _, n := range in { + t.Run(n, func(st *testing.T) { + r := require.New(st) + + f2 := WithName(n, f1) + + r.Equal(exp, f2.Name()) + }) + } +}