-
Notifications
You must be signed in to change notification settings - Fork 12
/
command_test.go
45 lines (35 loc) · 928 Bytes
/
command_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
package livestatus
import (
"fmt"
"testing"
"time"
)
func Test_Command(t *testing.T) {
expected := fmt.Sprintf("COMMAND [%d] command1\n\n", time.Now().Unix())
c := NewCommand("command1")
result := c.String()
if result != expected {
t.Logf("\nExpected %q\nbut got %q\n", expected, result)
t.Fail()
}
}
func Test_CommandWithInlineArgs(t *testing.T) {
expected := fmt.Sprintf("COMMAND [%d] command1;arg1;arg2\n\n", time.Now().Unix())
c := NewCommand("command1", "arg1", "arg2")
result := c.String()
if result != expected {
t.Logf("\nExpected %q\nbut got %q\n", expected, result)
t.Fail()
}
}
func Test_CommandWithArgs(t *testing.T) {
expected := fmt.Sprintf("COMMAND [%d] command1;arg1;arg2\n\n", time.Now().Unix())
c := NewCommand("command1")
c.Arg("arg1")
c.Arg("arg2")
result := c.String()
if result != expected {
t.Logf("\nExpected %q\nbut got %q\n", expected, result)
t.Fail()
}
}