-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcron_test.go
More file actions
118 lines (111 loc) · 2.15 KB
/
cron_test.go
File metadata and controls
118 lines (111 loc) · 2.15 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
package micron
import (
"context"
"errors"
"log/slog"
"testing"
"github.com/zalgonoise/cfg"
"github.com/zalgonoise/x/is"
"go.opentelemetry.io/otel/trace/noop"
"github.com/zalgonoise/micron/v3/log"
"github.com/zalgonoise/micron/v3/metrics"
"github.com/zalgonoise/micron/v3/selector"
)
func TestConfig(t *testing.T) {
for _, testcase := range []struct {
name string
opts []cfg.Option[*Runtime]
}{
{
name: "WithSelector/NilSelector",
opts: []cfg.Option[*Runtime]{
WithSelector(nil),
},
},
{
name: "WithSelector/NoOpSelector",
opts: []cfg.Option[*Runtime]{
WithSelector(selector.NoOp()),
},
},
{
name: "WithErrorBufferSize/Zero",
opts: []cfg.Option[*Runtime]{
WithErrorBufferSize(0),
},
},
{
name: "WithErrorBufferSize/Ten",
opts: []cfg.Option[*Runtime]{
WithErrorBufferSize(10),
},
},
{
name: "WithErrorBufferSize/Negative",
opts: []cfg.Option[*Runtime]{
WithErrorBufferSize(-10),
},
},
{
name: "WithMetrics/NilMetrics",
opts: []cfg.Option[*Runtime]{
WithMetrics(nil),
},
},
{
name: "WithMetrics/NoOp",
opts: []cfg.Option[*Runtime]{
WithMetrics(metrics.NoOp()),
},
},
{
name: "WithLogger/NilLogger",
opts: []cfg.Option[*Runtime]{
WithLogger(nil),
},
},
{
name: "WithLogger/NoOp",
opts: []cfg.Option[*Runtime]{
WithLogger(slog.New(log.NoOp())),
},
},
{
name: "WithLogHandler/NilHandler",
opts: []cfg.Option[*Runtime]{
WithLogHandler(nil),
},
},
{
name: "WithLogHandler/NoOp",
opts: []cfg.Option[*Runtime]{
WithLogHandler(log.NoOp()),
},
},
{
name: "WithTrace/NilTracer",
opts: []cfg.Option[*Runtime]{
WithTrace(nil),
},
},
{
name: "WithTrace/NoOp",
opts: []cfg.Option[*Runtime]{
WithTrace(noop.NewTracerProvider().Tracer("test")),
},
},
} {
t.Run(testcase.name, func(t *testing.T) {
_ = cfg.Set(new(Runtime), testcase.opts...)
})
}
}
func TestNoOp(t *testing.T) {
noOp := NoOp()
noOp.Run(context.Background())
is.Empty(t, noOp.Err())
}
func TestNew_NilSelector(t *testing.T) {
_, err := New(nil)
is.True(t, errors.Is(err, ErrEmptySelector))
}