package version import "testing" func TestDescribe(t *testing.T) { const c = "4d00be5e1f0a9b8c7d6e5f4a3b2c1d0e9f8a7b6c" for _, tc := range []struct { tag, commit string modified bool label, url string }{ {"v0.1.0", c, true, "v0.1.0", Repo + "/releases/tag/v0.1.0"}, {"", c, false, "4d00be5e1f0a", Repo + "/commit/" + c}, {"", c, true, "4d00be5e1f0a-modified", Repo + "/commit/" + c}, {"", "", false, "0.1.0", Repo}, } { b := describe("0.1.0", tc.tag, tc.commit, tc.modified) if b.Label != tc.label || b.URL != tc.url { t.Errorf("describe(%q, %q, %v) = %q %q, want %q %q", tc.tag, tc.commit, tc.modified, b.Label, b.URL, tc.label, tc.url) } } }