-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoption_test.go
59 lines (47 loc) · 1.54 KB
/
option_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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Copyright 2024 FishGoddess. All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.
package rego
import (
"context"
"fmt"
"testing"
)
// go test -v -cover -count=1 -test.cpu=1 -run=^TestWithLimit$
func TestWithLimit(t *testing.T) {
conf := &config{limit: 0}
WithLimit(64)(conf)
if conf.limit != 64 {
t.Fatalf("conf.limit %d is wrong", conf.limit)
}
}
// go test -v -cover -count=1 -test.cpu=1 -run=^TestWithFastFailed$
func TestWithFastFailed(t *testing.T) {
conf := &config{fastFailed: false}
WithFastFailed()(conf)
if !conf.fastFailed {
t.Fatalf("conf.fastFailed %+v is wrong", conf.fastFailed)
}
}
// go test -v -cover -count=1 -test.cpu=1 -run=^TestWithPoolFullErr$
func TestWithPoolFullErr(t *testing.T) {
newPoolFullErr := func(ctx context.Context) error {
return nil
}
conf := &config{newPoolFullErrFunc: nil}
WithPoolFullErr(newPoolFullErr)(conf)
if fmt.Sprintf("%p", conf.newPoolFullErrFunc) != fmt.Sprintf("%p", newPoolFullErr) {
t.Fatalf("conf.newPoolFullErrFunc %p is wrong", conf.newPoolFullErrFunc)
}
}
// go test -v -cover -count=1 -test.cpu=1 -run=^TestWithPoolClosedErr$
func TestWithPoolClosedErr(t *testing.T) {
newPoolClosedErr := func(ctx context.Context) error {
return nil
}
conf := &config{newPoolClosedErrFunc: nil}
WithPoolClosedErr(newPoolClosedErr)(conf)
if fmt.Sprintf("%p", conf.newPoolClosedErrFunc) != fmt.Sprintf("%p", newPoolClosedErr) {
t.Fatalf("conf.newPoolClosedErrFunc %p is wrong", conf.newPoolClosedErrFunc)
}
}