From 91eff80be8bc19dd3d22d21804bde08ed6a34d85 Mon Sep 17 00:00:00 2001 From: Brian Flad Date: Mon, 16 Dec 2019 19:29:34 -0500 Subject: [PATCH] tests/check: Add unit testing for FullPath --- check/file_test.go | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 check/file_test.go diff --git a/check/file_test.go b/check/file_test.go new file mode 100644 index 0000000..4dfea82 --- /dev/null +++ b/check/file_test.go @@ -0,0 +1,40 @@ +package check + +import ( + "testing" +) + +func TestFullPath(t *testing.T) { + testCases := []struct { + Name string + FileOptions *FileOptions + Path string + Expect string + }{ + { + Name: "without base path", + FileOptions: &FileOptions{}, + Path: "docs/resource/thing.md", + Expect: "docs/resource/thing.md", + }, + { + Name: "without base path", + FileOptions: &FileOptions{ + BasePath: "/full/path/to", + }, + Path: "docs/resource/thing.md", + Expect: "/full/path/to/docs/resource/thing.md", + }, + } + + for _, testCase := range testCases { + t.Run(testCase.Name, func(t *testing.T) { + got := testCase.FileOptions.FullPath(testCase.Path) + want := testCase.Expect + + if got != want { + t.Errorf("expected %s, got %s", want, got) + } + }) + } +}