mirror of
https://github.com/golang/oauth2.git
synced 2025-07-21 00:00:09 +08:00
Adds framework for sending BYOID metrics via the x-goog-api-client header on outgoing sts requests. Also adds a header file for getting the current version of GoLang Change-Id: Id5431def96f4cfc03e4ada01d5fb8cac8cfa56a9 GitHub-Last-Rev: c93cd478e5fade98bcf846164b9b56f89b442f6b GitHub-Pull-Request: golang/oauth2#661 Reviewed-on: https://go-review.googlesource.com/c/oauth2/+/523595 Reviewed-by: Leo Siracusa <leosiracusa@google.com> Run-TryBot: Cody Oss <codyoss@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cody Oss <codyoss@google.com>
49 lines
872 B
Go
49 lines
872 B
Go
// 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
|
|
}
|