-
Notifications
You must be signed in to change notification settings - Fork 101
/
topic_test.go
50 lines (43 loc) · 1.01 KB
/
topic_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
package main
import (
"os"
"reflect"
"testing"
)
func TestTopicParseArgs(t *testing.T) {
target := &topicCmd{}
givenBroker := "hans:9092"
expectedBrokers := []string{givenBroker}
os.Setenv(ENV_BROKERS, givenBroker)
target.parseArgs([]string{})
if !reflect.DeepEqual(target.brokers, expectedBrokers) {
t.Errorf(
"Expected brokers %v from env vars, got brokers %v.",
expectedBrokers,
target.brokers,
)
return
}
os.Setenv(ENV_BROKERS, "")
expectedBrokers = []string{"localhost:9092"}
target.parseArgs([]string{})
if !reflect.DeepEqual(target.brokers, expectedBrokers) {
t.Errorf(
"Expected brokers %v from env vars, got brokers %v.",
expectedBrokers,
target.brokers,
)
return
}
os.Setenv(ENV_BROKERS, "BLABB")
expectedBrokers = []string{givenBroker}
target.parseArgs([]string{"-brokers", givenBroker})
if !reflect.DeepEqual(target.brokers, expectedBrokers) {
t.Errorf(
"Expected brokers %v from env vars, got brokers %v.",
expectedBrokers,
target.brokers,
)
return
}
}