aboutsummaryrefslogtreecommitdiff
path: root/lib/lib_test.go
diff options
context:
space:
mode:
authorGrégoire Duchêne <gduchene@awhk.org>2020-03-26 22:00:40 +0000
committerGrégoire Duchêne <gduchene@awhk.org>2020-03-26 22:00:40 +0000
commit3216dc9b8d876f24ed561e81c2a1fb91926cb57a (patch)
tree9abb98e1741494d4856553335761904f5466baa0 /lib/lib_test.go
parent0d32b71317472ab5d93aa98f8db02609ed1318bc (diff)
Add a few test cases to lib
Diffstat (limited to 'lib/lib_test.go')
-rw-r--r--lib/lib_test.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/lib_test.go b/lib/lib_test.go
new file mode 100644
index 0000000..7b46bfb
--- /dev/null
+++ b/lib/lib_test.go
@@ -0,0 +1,23 @@
+// Copyright (c) 2019, Grégoire Duchêne <gduchene@awhk.org>
+//
+// Use of this source code is governed by the ISC license that can be
+// found in the LICENSE file.
+
+package lib
+
+import "testing"
+
+func TestGetDest(t *testing.T) {
+ cs := []struct{ srcPrefix, destPrefix, pkg, expected string }{
+ {"src.example.com/x/", "https://example.com/git/", "src.example.com/x/foo", "https://example.com/git/foo"},
+ {"src.example.com/x/", "https://example.com/git/", "src.example.com/x/foo/bar", "https://example.com/git/foo"},
+ {"src.example.com/x", "https://example.com/git", "src.example.com/x/foo", "https://example.com/git/foo"},
+ {"src.example.com/x", "https://example.com/git", "src.example.com/x/foo/bar", "https://example.com/git/foo"},
+ }
+ for _, c := range cs {
+ actual := GetDest(c.srcPrefix, c.destPrefix, c.pkg)
+ if actual != c.expected {
+ t.Errorf("expected %s, got %s", c.expected, actual)
+ }
+ }
+}