-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelper_test.go
62 lines (54 loc) · 1.39 KB
/
helper_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
package main
import (
"os"
"testing"
log "github.com/sirupsen/logrus"
)
func TestNewProducer(t *testing.T) {
os.Setenv("PRODUCER_MAX_MESSAGE_BYTES", "1000")
os.Setenv("PRODUCER_FLUSH_FREQUENCY", "10")
os.Setenv("PRODUCER_FLUSH_MESSAGE", "10")
os.Setenv("PRODUCER_FLUSH_MAX_MESSAGE", "10")
os.Setenv("PRODUCER_RETURN_SUCCESS", "true")
os.Setenv("PRODUCER_TIMEOUT", "50")
os.Setenv("PRODUCER_RETRY_MAX", "3")
os.Setenv("PRODUCER_RETRY_BACKOFF", "5")
os.Setenv("PRODUCER_RETURN_ERROR", "true")
os.Setenv("PRODUCER_COMPRESSIONLEVEL", "0")
os.Setenv("PRODUCER_CLIENTID", "sarama_test")
os.Setenv("PRODUCER_CHANNELBUFFERSIZE", "50")
os.Setenv("PRODUCER_VERSION", "2.6.0")
os.Setenv("PRODUCER_BROKERS", "localhost:9092")
_, err := newProducer()
if err != nil {
t.Error()
}
}
func TestTCompressionLevel(t *testing.T) {
os.Setenv("PRODUCER_COMPRESSIONLEVEL", "zstd")
response := compressionLevel()
if response != 4 {
t.Error(response)
}
}
func TestRequiredAcks(t *testing.T) {
os.Setenv("PRODUCER_REQUIRED_ACKS", "-1")
response := saramaPartitioner()
if response == nil {
t.Error()
}
}
func TestSaramaPartitioner(t *testing.T) {
os.Setenv("PRODUCER_PARTITIONER", "badvalue")
response := saramaPartitioner()
if response == nil {
t.Error()
}
}
func TestLogLevel(t *testing.T) {
os.Setenv("LOG_LEVEL", "badvalue")
response := logLevel()
if response != log.InfoLevel {
t.Error()
}
}