From e358753094074a6067c56fcc0cf71a918c1d0a60 Mon Sep 17 00:00:00 2001 From: Gabe Cook Date: Thu, 10 Mar 2022 03:25:05 -0600 Subject: [PATCH] :white_check_mark: Fix filename test --- cmd/dump/dump_test.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/cmd/dump/dump_test.go b/cmd/dump/dump_test.go index 5702fa41..f80bbff8 100644 --- a/cmd/dump/dump_test.go +++ b/cmd/dump/dump_test.go @@ -3,6 +3,7 @@ package dump import ( "fmt" "github.com/clevyr/kubedb/internal/database/sqlformat" + "path/filepath" "strings" "testing" ) @@ -18,16 +19,20 @@ func TestGenerateFilename(t *testing.T) { {"/home/test", "another", sqlformat.Plain, nil}, } for _, tc := range testCases { - tc := tc // capture range variable + tc := tc // capture range variable t.Run(fmt.Sprintf("%v in %v to %v with error %v", tc.directory, tc.namespace, tc.filetype, tc.err), func(t *testing.T) { - t.Parallel() - filename, err := generateFilename(tc.directory, tc.namespace, tc.filetype) + t.Parallel() + filename, err := Filename{ + Dir: tc.directory, + Namespace: tc.namespace, + Format: tc.filetype, + }.Generate() if err != tc.err { t.Error(err) } - expected := tc.directory + "/" + tc.namespace + "-" + expected := filepath.Clean(tc.directory + "/" + tc.namespace + "_") if !strings.HasPrefix(filename, expected) { - t.Errorf("got %v; expected %v", filename, expected) + t.Errorf("got %v; expected %#v", filename, expected) } }) }