File: header_test.go

package info (click to toggle)
golang-golang-x-oauth2 0.15.0-1~bpo12%2B1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-backports
  • size: 748 kB
  • sloc: makefile: 15
file content (48 lines) | stat: -rw-r--r-- 872 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright 2023 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package externalaccount

import (
	"runtime"
	"testing"

	"github.com/google/go-cmp/cmp"
)

func TestGoVersion(t *testing.T) {
	testVersion := func(v string) func() string {
		return func() string {
			return v
		}
	}
	for _, tst := range []struct {
		v    func() string
		want string
	}{
		{
			testVersion("go1.19"),
			"1.19.0",
		},
		{
			testVersion("go1.21-20230317-RC01"),
			"1.21.0-20230317-RC01",
		},
		{
			testVersion("devel +abc1234"),
			"abc1234",
		},
		{
			testVersion("this should be unknown"),
			versionUnknown,
		},
	} {
		version = tst.v
		got := goVersion()
		if diff := cmp.Diff(got, tst.want); diff != "" {
			t.Errorf("got(-),want(+):\n%s", diff)
		}
	}
	version = runtime.Version
}