From 80b5a6680e2fc4d2f1e425ff2e5f1cfbbd529d9e Mon Sep 17 00:00:00 2001 From: Grégoire Duchêne Date: Sun, 4 Jul 2021 15:33:18 +0100 Subject: Simplify project structure --- resp_test.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 resp_test.go (limited to 'resp_test.go') 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 +// +// 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) + } + } +} -- cgit v1.2.3-70-g09d2