From 78cbe6667b88cc5098fc97a83067111df2a47b15 Mon Sep 17 00:00:00 2001 From: Shawn Smith Date: Sat, 27 Nov 2021 15:55:30 +0900 Subject: [PATCH] add TestMakeFilename, TestFileURL --- check/utils_test.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/check/utils_test.go b/check/utils_test.go index df4bf9c..2fa4c5e 100644 --- a/check/utils_test.go +++ b/check/utils_test.go @@ -47,3 +47,35 @@ func TestGoTool(t *testing.T) { } } } + +func TestMakeFilename(t *testing.T) { + cases := []struct { + fn string + want string + }{ + {"/github.com/foo/bar/baz.go", "bar/baz.go"}, + } + + for _, tt := range cases { + if got := makeFilename(tt.fn); got != tt.want { + t.Errorf("makeFilename(%q) = %q, want %q", tt.fn, got, tt.want) + } + } +} + +func TestFileURL(t *testing.T) { + cases := []struct { + dir string + fn string + want string + }{ + {"_repos/src/github.com/foo/bar/baz.go", "/github.com/foo/bar/baz.go", "https://github.com/foo/bar/blob/master/baz.go"}, + } + + for _, tt := range cases { + if got := fileURL(tt.dir, tt.fn); got != tt.want { + t.Errorf("fileURL(%q, %q) = %q, want %q", tt.dir, tt.fn, got, tt.want) + } + } + +}