-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrefresh_test.go
40 lines (35 loc) · 934 Bytes
/
refresh_test.go
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
package main
import (
"context"
"io"
"log"
"testing"
)
// This file is required for command-line testing because `go test` requires that tests be in a file that ends with `_test.go`.
//
// The Go playground happily runs the `refresh.go` file and executes the test in there when it finds no main function.
// Wrapper function to call the test function in `refresh.go`.
func TestWrapTokenGet(t *testing.T) {
TestTokenGet(t)
}
func TestWrapMTokenGet(t *testing.T) {
TestMTokenGet(t)
}
func BenchmarkToken_Get(b *testing.B) {
log.SetOutput(io.Discard)
ctx, cancel := context.WithCancel(context.Background())
t := NewToken(ctx, authFunc)
defer cancel()
for i := 0; i < b.N; i++ {
_, _ = t.Get()
}
}
func BenchmarkMToken_Get(b *testing.B) {
log.SetOutput(io.Discard)
ctx, cancel := context.WithCancel(context.Background())
t := NewToken(ctx, authFunc)
defer cancel()
for i := 0; i < b.N; i++ {
_, _ = t.Get()
}
}