-
Notifications
You must be signed in to change notification settings - Fork 112
Expand file tree
/
Copy pathcreate_test.go
More file actions
73 lines (52 loc) · 1.55 KB
/
create_test.go
File metadata and controls
73 lines (52 loc) · 1.55 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
package fleet
import (
"io/ioutil"
"path"
"sync"
"testing"
"github.com/deis/deis/deisctl/config/model"
"github.com/deis/deis/deisctl/test/mock"
"github.com/coreos/fleet/schema"
)
func TestCreate(t *testing.T) {
t.Parallel()
unitFiles := []string{"deis-controller.service", "deis-builder.service",
"deis-router.service"}
unitContents := []byte("[Unit]")
name, err := ioutil.TempDir("", "deisctl-fleetctl")
if err != nil {
t.Fatal(err)
}
for _, unit := range unitFiles {
ioutil.WriteFile(path.Join(name, unit), unitContents, 777)
}
testFleetClient := stubFleetClient{testUnits: []*schema.Unit{}, unitsMutex: &sync.Mutex{},
unitStatesMutex: &sync.Mutex{}}
testConfigBackend := mock.ConfigBackend{Expected: []*model.ConfigNode{{Key: "/deis/platform/enablePlacementOptions", Value: "true"}}}
c := &FleetClient{templatePaths: []string{name}, Fleet: &testFleetClient, configBackend: testConfigBackend}
var errOutput string
var wg sync.WaitGroup
logMutex := sync.Mutex{}
se := newOutErr()
c.Create([]string{"controller", "builder", "router@1"}, &wg, se.out, se.ew)
wg.Wait()
logMutex.Lock()
if errOutput != "" {
t.Fatal(errOutput)
}
logMutex.Unlock()
expectedUnits := []string{"deis-controller.service", "deis-builder.service",
"deis-router@1.service"}
for _, expectedUnit := range expectedUnits {
found := false
for _, unit := range testFleetClient.testUnits {
if unit.Name == expectedUnit {
found = true
break
}
}
if !found {
t.Errorf("Expected Unit %s not found in Unit States", expectedUnit)
}
}
}