-
Notifications
You must be signed in to change notification settings - Fork 16
/
main_test.go
57 lines (43 loc) · 1.21 KB
/
main_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
// Copyright (C) 2017 Jan Delgado
package main
import (
"errors"
"testing"
"github.com/jandelgado/rabtap/pkg/testcommon"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
)
func TestInitLogging(t *testing.T) {
initLogging(false)
assert.Equal(t, logrus.WarnLevel, log.Level)
initLogging(true)
assert.Equal(t, logrus.DebugLevel, log.Level)
initLogging(false)
}
func TestGetTLSConfig(t *testing.T) {
tls := getTLSConfig(true)
assert.True(t, tls.InsecureSkipVerify)
tls = getTLSConfig(false)
assert.False(t, tls.InsecureSkipVerify)
}
func TestFailOnError(t *testing.T) {
exitFuncCalled := false
exitFunc := func(int) {
exitFuncCalled = true
}
// error case
failOnError(errors.New("error"), "error test", exitFunc)
assert.True(t, exitFuncCalled)
// no error case
exitFuncCalled = false
failOnError(nil, "test", exitFunc)
assert.False(t, exitFuncCalled)
}
func ExamplestartCmdInfo() {
mock := testcommon.NewRabbitAPIMock(testcommon.MockModeEmpty)
defer mock.Close()
args := CommandLineArgs{APIURI: mock.URL, commonArgs: commonArgs{NoColor: true}}
startCmdInfo(args, "http://rootnode")
// Output:
// http://rootnode (broker ver=3.6.9, mgmt ver=3.6.9, cluster=rabbit@08f57d1fe8ab)
}