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