-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdestroy_test.go
More file actions
48 lines (36 loc) · 1.01 KB
/
destroy_test.go
File metadata and controls
48 lines (36 loc) · 1.01 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
package fleet
import (
"sync"
"testing"
"github.com/coreos/fleet/schema"
)
func TestDestroy(t *testing.T) {
t.Parallel()
testUnits := []*schema.Unit{
&schema.Unit{
Name: "deis-registry.service",
},
&schema.Unit{
Name: "deis-builder.service",
},
&schema.Unit{
Name: "deis-router@1.service",
},
}
testFleetClient := stubFleetClient{testUnits: testUnits, testUnitStates: []*schema.UnitState{}, unitsMutex: &sync.Mutex{}, unitStatesMutex: &sync.Mutex{}}
c := &FleetClient{Fleet: &testFleetClient}
var errOutput string
var wg sync.WaitGroup
logMutex := sync.Mutex{}
oe := newOutErr()
c.Destroy([]string{"controller", "registry", "router@1"}, &wg, oe.out, oe.ew)
wg.Wait()
logMutex.Lock()
if errOutput != "" {
t.Fatal(errOutput)
}
logMutex.Unlock()
if len(testFleetClient.testUnits) != 1 || testFleetClient.testUnits[0].Name != "deis-builder.service" {
t.Errorf("Got %d Units (want 1), first unit %s (want builder)", len(testFleetClient.testUnits), testFleetClient.testUnits[0].Name)
}
}