aboutsummaryrefslogtreecommitdiff
path: root/resp_test.go
blob: 4afbd92c1f1de253bda3d7be27a24ce64c7f9458 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// SPDX-FileCopyrightText: © 2019 Grégoire Duchêne <gduchene@awhk.org>
// SPDX-License-Identifier: ISC

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)
		}
	}
}