aboutsummaryrefslogtreecommitdiff
path: root/internal/stdlib/stdlib_test.go
diff options
context:
space:
mode:
authorJonathan Amsterdam <jba@google.com>2019-11-01 16:30:21 -0400
committerJulie Qiu <julie@golang.org>2020-03-27 16:46:46 -0400
commitb322ae09c0174ecd3686861ae1185d6844b281fd (patch)
tree501caf6b98bd011443d1a4cbeb28a054cc441f0b /internal/stdlib/stdlib_test.go
parent34a56cf3dc22ba8973b8379a4e307a0519500195 (diff)
downloadgo-x-pkgsite-b322ae09c0174ecd3686861ae1185d6844b281fd.tar.xz
internal/frontend: fix major version for std
Display the major version as "go1", not "v1". Also, fix the tooltip. Fixes b/143529585. Fixes b/143613230. Change-Id: I3379e8295a90f79c375f6e54e3593eee2391a335 Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/589902 CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com> Reviewed-by: Julie Qiu <julieqiu@google.com>
Diffstat (limited to 'internal/stdlib/stdlib_test.go')
-rw-r--r--internal/stdlib/stdlib_test.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/internal/stdlib/stdlib_test.go b/internal/stdlib/stdlib_test.go
index 65aecec4..eca3760d 100644
--- a/internal/stdlib/stdlib_test.go
+++ b/internal/stdlib/stdlib_test.go
@@ -83,6 +83,27 @@ func TestTagForVersion(t *testing.T) {
}
}
+func TestMajorVersionForVersion(t *testing.T) {
+ for _, test := range []struct {
+ in string
+ want string // empty => error
+ }{
+ {"", ""},
+ {"garbage", ""},
+ {"v1.13.3", "go1"},
+ {"v1.9.0-rc.2", "go1"},
+ {"v2.1.3", "go2"},
+ } {
+ got, err := MajorVersionForVersion(test.in)
+ if (err != nil) != (test.want == "") {
+ t.Errorf("%q: err: got %v, wanted error: %t", test.in, err, test.want == "")
+ }
+ if err == nil && got != test.want {
+ t.Errorf("%q: got %q, want %q", test.in, got, test.want)
+ }
+ }
+}
+
func TestZip(t *testing.T) {
UseTestData = true
defer func() { UseTestData = false }()