-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathlist_unit_files_test.go
More file actions
85 lines (73 loc) · 1.72 KB
/
list_unit_files_test.go
File metadata and controls
85 lines (73 loc) · 1.72 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package fleet
import (
"bytes"
"fmt"
"sync"
"testing"
"text/tabwriter"
"github.com/coreos/fleet/machine"
"github.com/coreos/fleet/schema"
)
func TestListUnitFiles(t *testing.T) {
t.Parallel()
testUnits := []*schema.Unit{
&schema.Unit{
Name: "deis-controller.service",
DesiredState: "launched",
CurrentState: "launched",
MachineID: "123456",
Options: []*schema.UnitOption{
&schema.UnitOption{
Section: "Unit",
Name: "Description",
Value: "deis-controller",
},
},
},
&schema.Unit{
Name: "deis-router@1.service",
DesiredState: "launched",
CurrentState: "launched",
MachineID: "654321",
Options: []*schema.UnitOption{
&schema.UnitOption{
Section: "Unit",
Name: "Description",
Value: "deis-router@1",
},
},
},
}
testMachines := []machine.MachineState{
machine.MachineState{
ID: "123456",
PublicIP: "1.1.1.1",
Metadata: nil,
Version: "",
},
machine.MachineState{
ID: "654321",
PublicIP: "2.2.2.2",
Metadata: nil,
Version: "",
},
}
testWriter := bytes.Buffer{}
testTabWriter := new(tabwriter.Writer)
testTabWriter.Init(&testWriter, 0, 8, 1, '\t', 0)
c := &FleetClient{Fleet: &stubFleetClient{testUnits: testUnits,
testMachineStates: testMachines, unitsMutex: &sync.Mutex{}},
out: testTabWriter}
err := c.ListUnitFiles()
if err != nil {
t.Fatal(err)
}
expected := `UNIT HASH DSTATE STATE TMACHINE
deis-controller.service 61030e3 launched launched 123456.../1.1.1.1
deis-router@1.service 1182ecf launched launched 654321.../2.2.2.2
`
actual := testWriter.String()
if expected != actual {
t.Error(fmt.Errorf("Expected '%s', Got '%s'", expected, actual))
}
}