-
Notifications
You must be signed in to change notification settings - Fork 171
Expand file tree
/
Copy pathdeployments_test.go
More file actions
99 lines (81 loc) · 2.39 KB
/
Copy pathdeployments_test.go
File metadata and controls
99 lines (81 loc) · 2.39 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package cmd_test
import (
"errors"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/cloudfoundry/bosh-cli/v7/cmd"
boshdir "github.com/cloudfoundry/bosh-cli/v7/director"
fakedir "github.com/cloudfoundry/bosh-cli/v7/director/directorfakes"
fakeui "github.com/cloudfoundry/bosh-cli/v7/ui/fakes"
boshtbl "github.com/cloudfoundry/bosh-cli/v7/ui/table"
)
var _ = Describe("DeploymentsCmd", func() {
var (
ui *fakeui.FakeUI
director *fakedir.FakeDirector
command cmd.DeploymentsCmd
)
BeforeEach(func() {
ui = &fakeui.FakeUI{}
director = &fakedir.FakeDirector{}
command = cmd.NewDeploymentsCmd(ui, director)
})
Describe("Run", func() {
act := func() error { return command.Run() }
It("lists deployments", func() {
deployments := []boshdir.DeploymentResp{
boshdir.DeploymentResp{
Name: "dep1",
Teams: []string{"team1", "team2"},
Releases: []boshdir.DeploymentReleaseResp{
boshdir.DeploymentReleaseResp{
Name: "rel1",
Version: "rel1-ver",
},
boshdir.DeploymentReleaseResp{
Name: "rel2",
Version: "rel2-ver",
},
},
Stemcells: []boshdir.DeploymentStemcellResp{
boshdir.DeploymentStemcellResp{
Name: "stemcell1",
Version: "stemcell1-ver",
},
boshdir.DeploymentStemcellResp{
Name: "stemcell2",
Version: "stemcell2-ver",
},
},
},
}
director.ListDeploymentsReturns(deployments, nil)
err := act()
Expect(err).ToNot(HaveOccurred())
Expect(ui.Table).To(Equal(boshtbl.Table{
Content: "deployments",
Header: []boshtbl.Header{
boshtbl.NewHeader("Name"),
boshtbl.NewHeader("Release(s)"),
boshtbl.NewHeader("Stemcell(s)"),
boshtbl.NewHeader("Team(s)"),
},
SortBy: []boshtbl.ColumnSort{{Column: 0, Asc: true}},
Rows: [][]boshtbl.Value{
{
boshtbl.NewValueString("dep1"),
boshtbl.NewValueStrings([]string{"rel1/rel1-ver", "rel2/rel2-ver"}),
boshtbl.NewValueStrings([]string{"stemcell1/stemcell1-ver", "stemcell2/stemcell2-ver"}),
boshtbl.NewValueStrings([]string{"team1", "team2"}),
},
},
}))
})
It("returns error if deployments cannot be retrieved", func() {
director.ListDeploymentsReturns(nil, errors.New("fake-err"))
err := act()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-err"))
})
})
})