diff options
Diffstat (limited to 'resp_test.go')
| -rw-r--r-- | resp_test.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/resp_test.go b/resp_test.go new file mode 100644 index 0000000..4dadf74 --- /dev/null +++ b/resp_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 main + +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) + } + } +} |
