Skip to content

Commit f6c96ea

Browse files
Kevin KelaniZachary Gershman
Kevin Kelani
authored and
Zachary Gershman
committed
remove nil check
[#140880833] Signed-off-by: Zachary Gershman <[email protected]>
1 parent a67f737 commit f6c96ea

File tree

2 files changed

+15
-17
lines changed

2 files changed

+15
-17
lines changed

commands/errands.go

+10-16
Original file line numberDiff line numberDiff line change
@@ -62,24 +62,18 @@ func (e Errands) Execute(args []string) error {
6262
for _, errand := range errandsOutput.Errands {
6363
var postDeploy, preDelete string
6464

65-
if errand.PreDelete != nil {
66-
switch p := errand.PreDelete.(type) {
67-
case string:
68-
preDelete = p
69-
case bool:
70-
preDelete = strconv.FormatBool(p)
71-
}
72-
} else {
73-
preDelete = ""
65+
switch p := errand.PreDelete.(type) {
66+
case string:
67+
preDelete = p
68+
case bool:
69+
preDelete = strconv.FormatBool(p)
7470
}
7571

76-
if errand.PostDeploy != nil {
77-
switch p := errand.PostDeploy.(type) {
78-
case string:
79-
postDeploy = p
80-
case bool:
81-
postDeploy = strconv.FormatBool(p)
82-
}
72+
switch p := errand.PostDeploy.(type) {
73+
case string:
74+
postDeploy = p
75+
case bool:
76+
postDeploy = strconv.FormatBool(p)
8377
}
8478

8579
e.tableWriter.Append([]string{errand.Name, postDeploy, preDelete})

commands/errands_test.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ var _ = Describe("Errands", func() {
3333
{Name: "first-errand", PostDeploy: "true"},
3434
{Name: "second-errand", PostDeploy: "false"},
3535
{Name: "third-errand", PreDelete: true},
36+
{Name: "will-not-appear", PreDelete: nil},
37+
{Name: "also-bad", PostDeploy: nil},
3638
},
3739
}, nil)
3840

@@ -55,10 +57,12 @@ var _ = Describe("Errands", func() {
5557
Expect(tableWriter.SetHeaderCallCount()).To(Equal(1))
5658
Expect(tableWriter.SetHeaderArgsForCall(0)).To(Equal([]string{"Name", "Post Deploy Enabled", "Pre Delete Enabled"}))
5759

58-
Expect(tableWriter.AppendCallCount()).To(Equal(3))
60+
Expect(tableWriter.AppendCallCount()).To(Equal(5))
5961
Expect(tableWriter.AppendArgsForCall(0)).To(Equal([]string{"first-errand", "true", ""}))
6062
Expect(tableWriter.AppendArgsForCall(1)).To(Equal([]string{"second-errand", "false", ""}))
6163
Expect(tableWriter.AppendArgsForCall(2)).To(Equal([]string{"third-errand", "", "true"}))
64+
Expect(tableWriter.AppendArgsForCall(3)).To(Equal([]string{"will-not-appear", "", ""}))
65+
Expect(tableWriter.AppendArgsForCall(4)).To(Equal([]string{"also-bad", "", ""}))
6266

6367
Expect(tableWriter.RenderCallCount()).To(Equal(1))
6468
})

0 commit comments

Comments
 (0)