...
1
2
3
4
5 package externalaccount
6
7 import (
8 "runtime"
9 "testing"
10
11 "github.com/google/go-cmp/cmp"
12 )
13
14 func TestGoVersion(t *testing.T) {
15 testVersion := func(v string) func() string {
16 return func() string {
17 return v
18 }
19 }
20 for _, tst := range []struct {
21 v func() string
22 want string
23 }{
24 {
25 testVersion("go1.19"),
26 "1.19.0",
27 },
28 {
29 testVersion("go1.21-20230317-RC01"),
30 "1.21.0-20230317-RC01",
31 },
32 {
33 testVersion("devel +abc1234"),
34 "abc1234",
35 },
36 {
37 testVersion("this should be unknown"),
38 versionUnknown,
39 },
40 } {
41 version = tst.v
42 got := goVersion()
43 if diff := cmp.Diff(got, tst.want); diff != "" {
44 t.Errorf("got(-),want(+):\n%s", diff)
45 }
46 }
47 version = runtime.Version
48 }
49
View as plain text