forked from fgeller/kt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
topic_test.go
42 lines (31 loc) · 960 Bytes
/
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
package main
import (
"testing"
qt "github.com/frankban/quicktest"
)
func TestTopicParseArgsUsesEnvVar(t *testing.T) {
c := qt.New(t)
c.Setenv(ENV_BROKERS, "hans:2000")
cmd0, _, err := parseCmd("hkt", "topic")
c.Assert(err, qt.Equals, nil)
cmd := cmd0.(*topicCmd)
c.Assert(cmd.brokers(), qt.DeepEquals, []string{"hans:2000"})
}
// brokers default to localhost:9092
func TestTopicParseArgsDefault(t *testing.T) {
c := qt.New(t)
c.Setenv(ENV_BROKERS, "")
cmd0, _, err := parseCmd("hkt", "topic")
c.Assert(err, qt.Equals, nil)
cmd := cmd0.(*topicCmd)
c.Assert(cmd.brokers(), qt.DeepEquals, []string{"localhost:9092"})
}
func TestTopicParseArgsFlagsOverrideEnv(t *testing.T) {
c := qt.New(t)
// command line arg wins
c.Setenv(ENV_BROKERS, "BLABB")
cmd0, _, err := parseCmd("hkt", "topic", "-brokers", "hans:2000")
c.Assert(err, qt.Equals, nil)
cmd := cmd0.(*topicCmd)
c.Assert(cmd.brokers(), qt.DeepEquals, []string{"hans:2000"})
}