github.com/secman-team/gh-api@v1.8.2/pkg/cmd/version/version_test.go (about) 1 package version 2 3 import ( 4 "testing" 5 ) 6 7 func TestFormat(t *testing.T) { 8 expects := "gh version 1.4.0 (2020-12-15)\nhttps://github.com/secman-team/gh-api/releases/tag/v1.4.0\n" 9 if got := Format("1.4.0", "2020-12-15"); got != expects { 10 t.Errorf("Format() = %q, wants %q", got, expects) 11 } 12 } 13 14 func TestChangelogURL(t *testing.T) { 15 tag := "0.3.2" 16 url := "https://github.com/secman-team/gh-api/releases/tag/v0.3.2" 17 result := changelogURL(tag) 18 if result != url { 19 t.Errorf("expected %s to create url %s but got %s", tag, url, result) 20 } 21 22 tag = "v0.3.2" 23 url = "https://github.com/secman-team/gh-api/releases/tag/v0.3.2" 24 result = changelogURL(tag) 25 if result != url { 26 t.Errorf("expected %s to create url %s but got %s", tag, url, result) 27 } 28 29 tag = "0.3.2-pre.1" 30 url = "https://github.com/secman-team/gh-api/releases/tag/v0.3.2-pre.1" 31 result = changelogURL(tag) 32 if result != url { 33 t.Errorf("expected %s to create url %s but got %s", tag, url, result) 34 } 35 36 tag = "0.3.5-90-gdd3f0e0" 37 url = "https://github.com/secman-team/gh-api/releases/latest" 38 result = changelogURL(tag) 39 if result != url { 40 t.Errorf("expected %s to create url %s but got %s", tag, url, result) 41 } 42 43 tag = "deadbeef" 44 url = "https://github.com/secman-team/gh-api/releases/latest" 45 result = changelogURL(tag) 46 if result != url { 47 t.Errorf("expected %s to create url %s but got %s", tag, url, result) 48 } 49 }