mirror of
https://github.com/golang/oauth2.git
synced 2025-07-21 00:00:09 +08:00
Change-Id: Ic8496d10de47181f6b9c16360b5101c6314d71ee Reviewed-on: https://go-review.googlesource.com/1653 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
31 lines
757 B
Go
31 lines
757 B
Go
// Copyright 2014 The oauth2 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 oauth2
|
|
|
|
import "testing"
|
|
|
|
func TestTokenExtra(t *testing.T) {
|
|
type testCase struct {
|
|
key string
|
|
val interface{}
|
|
want interface{}
|
|
}
|
|
const key = "extra-key"
|
|
cases := []testCase{
|
|
{key: key, val: "abc", want: "abc"},
|
|
{key: key, val: 123, want: 123},
|
|
{key: key, val: "", want: ""},
|
|
{key: "other-key", val: "def", want: nil},
|
|
}
|
|
for _, tc := range cases {
|
|
extra := make(map[string]interface{})
|
|
extra[tc.key] = tc.val
|
|
tok := &Token{raw: extra}
|
|
if got, want := tok.Extra(key), tc.want; got != want {
|
|
t.Errorf("Extra(%q) = %q; want %q", key, got, want)
|
|
}
|
|
}
|
|
}
|