forked from bitdabbler/fluent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathencoderOptions_test.go
98 lines (86 loc) · 2.17 KB
/
encoderOptions_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
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
package fluent
import (
"testing"
)
func TestWitheventMode(t *testing.T) {
p, err := NewEncoderPool(testTag, nil)
if err != nil {
t.Fatal(err)
}
if p.Mode != MessageMode {
t.Fatal("expected default for `Mode` to be eventMode")
}
p, err = NewEncoderPool(testTag, &EncoderOptions{Mode: ForwardMode})
if err != nil {
t.Fatal(err)
}
if p.Mode != ForwardMode {
t.Fatal("expected `Mode` to be FowardMode")
}
}
func TestWithNewBufferCap(t *testing.T) {
p, err := NewEncoderPool(testTag, nil)
if err != nil {
t.Fatal(err)
}
if p.NewBufferCap != defaultNewBufferCap {
t.Fatalf("expected newBufferCap default to be: %d, got: %d", defaultNewBufferCap, p.NewBufferCap)
}
cap := 16 << 10
p, err = NewEncoderPool(testTag, &EncoderOptions{NewBufferCap: cap})
if err != nil {
t.Fatal(err)
}
if p.NewBufferCap != cap {
t.Fatalf("expected NewBufferCap to be: %d, got: %d`", cap, p.NewBufferCap)
}
}
func TestWithMaxBufferCap(t *testing.T) {
p, err := NewEncoderPool(testTag, nil)
if err != nil {
t.Fatal(err)
}
if p.MaxBufferCap != defaultMaxBufferCap {
t.Fatalf("expected MaxBufferCap default to be: %d, got: %d", defaultMaxBufferCap, p.MaxBufferCap)
}
cap := 32 << 10
p, err = NewEncoderPool(testTag, &EncoderOptions{MaxBufferCap: cap})
if err != nil {
t.Fatal(err)
}
if p.MaxBufferCap != cap {
t.Fatalf("expected MaxBufferCap to be: %d, got: %d`", cap, p.MaxBufferCap)
}
}
func TestWithCoarseTimestamps(t *testing.T) {
p, err := NewEncoderPool(testTag, nil)
if err != nil {
t.Fatal(err)
}
if p.UseCoarseTimestamps {
t.Fatal("expected default for `UseCoarseTimestamps` to be false")
}
p, err = NewEncoderPool(testTag, &EncoderOptions{UseCoarseTimestamps: true})
if err != nil {
t.Fatal(err)
}
if !p.UseCoarseTimestamps {
t.Fatal("expected`UseCoarseTimestamps` to be true")
}
}
func TestWithRequestACK(t *testing.T) {
p, err := NewEncoderPool(testTag, nil)
if err != nil {
t.Fatal(err)
}
if p.RequestACKs {
t.Fatal("expected default for `RequestACKs` to be false")
}
p, err = NewEncoderPool(testTag, &EncoderOptions{RequestACKs: true})
if err != nil {
t.Fatal(err)
}
if !p.RequestACKs {
t.Fatal("expected`requestACK` to be true")
}
}