aboutsummaryrefslogtreecommitdiff
path: root/common_test.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2018-05-27 01:51:46 +0700
committerShulhan <ms@kilabit.info>2018-05-27 02:34:34 +0700
commitc8ec4eef5463d072717fc1a2ce96d5a2dc873a74 (patch)
tree49bc40b23dc4a8b383aa9efdf64b08d38e41f283 /common_test.go
parent8899b54af622ccfd18d7d1b9ef8903801fe64005 (diff)
downloadbeku-c8ec4eef5463d072717fc1a2ce96d5a2dc873a74.tar.xz
env.SyncAll: display compare URL for manual reviewing
Diffstat (limited to 'common_test.go')
-rw-r--r--common_test.go43
1 files changed, 43 insertions, 0 deletions
diff --git a/common_test.go b/common_test.go
index 5080a37..ffdc5c5 100644
--- a/common_test.go
+++ b/common_test.go
@@ -9,6 +9,49 @@ import (
"github.com/shuLhan/share/lib/test"
)
+func TestGetCompareURL(t *testing.T) {
+ cases := []struct {
+ desc string
+ remoteURL string
+ oldVer string
+ newVer string
+ exp string
+ }{{
+ desc: "With empty remoteURL",
+ }, {
+ desc: "With git format",
+ remoteURL: "git@github.com:shuLhan/beku.git",
+ oldVer: "A",
+ newVer: "B",
+ exp: "https://github.com/shuLhan/beku/compare/A...B",
+ }, {
+ desc: "With HTTP format",
+ remoteURL: "https://github.com/shuLhan/beku",
+ oldVer: "A",
+ newVer: "B",
+ exp: "https://github.com/shuLhan/beku/compare/A...B",
+ }, {
+ desc: "With golang.org as hostname",
+ remoteURL: "https://golang.org/x/net",
+ oldVer: "A",
+ newVer: "B",
+ exp: "https://github.com/golang/net/compare/A...B",
+ }, {
+ desc: "With unknown hostname",
+ remoteURL: "https://gopkg.in/yaml.v2",
+ oldVer: "A",
+ newVer: "B",
+ }}
+
+ for _, c := range cases {
+ t.Log(c.desc)
+
+ got := GetCompareURL(c.remoteURL, c.oldVer, c.newVer)
+
+ test.Assert(t, "", c.exp, got, true)
+ }
+}
+
func TestIsDirEmpty(t *testing.T) {
emptyDir := "testdata/dirempty"
err := os.MkdirAll(emptyDir, 0700)