Skip to content

Commit 37c069d

Browse files
Ramkishor ChaladiRamkishor Chaladi
authored andcommitted
removed descriptions and added unit test coverage for sortby
1 parent c260d67 commit 37c069d

6 files changed

Lines changed: 77 additions & 9 deletions

File tree

plugin/commands/block/replica_order.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ func NewReplicaOrderCommand(sl *metadata.SoftlayerStorageCommand) *ReplicaOrderC
3535
Short: T("Order a block storage replica volume"),
3636
Long: T(`${COMMAND_NAME} sl {{.storageType}} replica-order VOLUME_ID [OPTIONS]
3737
38-
Order a block storage replica volume.
39-
4038
EXAMPLE:
4139
${COMMAND_NAME} sl {{.storageType}} replica-order 12345678 -s DAILY -d dal09 --tier 4 --os-type LINUX
4240
This command orders a replica for volume with ID 12345678, which performs DAILY replication, is located at dal09, tier level is 4, OS type is Linux.`, sl.StorageI18n),

plugin/commands/block/replica_partners.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func (cmd *ReplicaPartnersCommand) Run(args []string) error {
8585
if len(partners) == 0 {
8686
cmd.UI.Print(T("There are no replication partners for volume {{.VolumeID}}.\n", subs))
8787
} else {
88-
table := cmd.UI.Table([]string{T("id"), T("username"), T("accountId"), T("capacityGb"), T("hardwareId"), T("guestId"), T("hostId")})
88+
table := cmd.UI.Table([]string{T("ID"), T("User name"), T("Account ID"), T("Capacity (GB)"), T("Hardware ID"), T("Guest ID"), T("Host ID")})
8989
for _, p := range partners {
9090
table.Add(
9191
utils.FormatIntPointer(p.Id),

plugin/commands/block/replica_partners_test.go

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,5 +84,81 @@ var _ = Describe("Replica partners", func() {
8484
Expect(fakeUI.Outputs()).To(ContainSubstring("There are no replication partners for volume 1234."))
8585
})
8686
})
87+
Context("Replica partners with correct volume id and --sortby id", func() {
88+
BeforeEach(func() {
89+
FakeStorageManager.GetReplicationPartnersReturns(nil, nil)
90+
})
91+
It("return table", func() {
92+
err := testhelpers.RunCobraCommand(cliCommand.Command, "442707460", "--sortby=id")
93+
Expect(err).NotTo(HaveOccurred())
94+
Expect(fakeUI.Outputs()).To(ContainSubstring("442707460"))
95+
})
96+
})
97+
98+
Context("Replica partners with correct volume id and --sortby accountId", func() {
99+
BeforeEach(func() {
100+
FakeStorageManager.GetReplicationPartnersReturns(nil, nil)
101+
})
102+
It("return table", func() {
103+
err := testhelpers.RunCobraCommand(cliCommand.Command, "307608", "--sortby=accountId")
104+
Expect(err).NotTo(HaveOccurred())
105+
Expect(fakeUI.Outputs()).To(ContainSubstring("307608"))
106+
})
107+
})
108+
109+
Context("Replica partners with correct volume id and --sortby capacityGb", func() {
110+
BeforeEach(func() {
111+
FakeStorageManager.GetReplicationPartnersReturns(nil, nil)
112+
})
113+
It("return table", func() {
114+
err := testhelpers.RunCobraCommand(cliCommand.Command, "25", "--sortby=capacityGb")
115+
Expect(err).NotTo(HaveOccurred())
116+
Expect(fakeUI.Outputs()).To(ContainSubstring("25"))
117+
})
118+
})
119+
120+
Context("Replica partners with correct volume id and --sortby hardwareId", func() {
121+
BeforeEach(func() {
122+
FakeStorageManager.GetReplicationPartnersReturns(nil, nil)
123+
})
124+
It("return table", func() {
125+
err := testhelpers.RunCobraCommand(cliCommand.Command, "1234", "--sortby=hardwareId")
126+
Expect(err).NotTo(HaveOccurred())
127+
Expect(fakeUI.Outputs()).To(ContainSubstring("1234"))
128+
})
129+
})
130+
131+
Context("Replica partners with correct volume id and --sortby guestId", func() {
132+
BeforeEach(func() {
133+
FakeStorageManager.GetReplicationPartnersReturns(nil, nil)
134+
})
135+
It("return table", func() {
136+
err := testhelpers.RunCobraCommand(cliCommand.Command, "1234", "--sortby=guestId")
137+
Expect(err).NotTo(HaveOccurred())
138+
Expect(fakeUI.Outputs()).To(ContainSubstring("1234"))
139+
})
140+
})
141+
142+
Context("Replica partners with correct volume id and --sortby hostId", func() {
143+
BeforeEach(func() {
144+
FakeStorageManager.GetReplicationPartnersReturns(nil, nil)
145+
})
146+
It("return table", func() {
147+
err := testhelpers.RunCobraCommand(cliCommand.Command, "1234", "--sortby=hostId")
148+
Expect(err).NotTo(HaveOccurred())
149+
Expect(fakeUI.Outputs()).To(ContainSubstring("1234"))
150+
})
151+
})
152+
153+
Context("Replica partners with correct volume id and --sortby abcd", func() {
154+
BeforeEach(func() {
155+
FakeStorageManager.GetReplicationPartnersReturns(nil, nil)
156+
})
157+
It("return error", func() {
158+
err := testhelpers.RunCobraCommand(cliCommand.Command, "1234", "--sortby=abcd")
159+
Expect(err).To(HaveOccurred())
160+
Expect(err.Error()).To(ContainSubstring("Incorrect Usage: --sortby 'abcd' is not supported."))
161+
})
162+
})
87163
})
88164
})

plugin/commands/block/snapshot_cancel.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ func NewSnapshotCancelCommand(sl *metadata.SoftlayerStorageCommand) *SnapshotCan
3030
Short: T("Cancel existing snapshot space for a given volume"),
3131
Long: T(`${COMMAND_NAME} sl {{.storageType}} snapshot-cancel SNAPSHOT_ID [OPTIONS]
3232
33-
Cancel existing snapshot space for a given volume.
34-
3533
EXAMPLE:
3634
${COMMAND_NAME} sl {{.storageType}} snapshot-cancel 12345678 --immediate -f
3735
This command cancels snapshot with ID 12345678 immediately without asking for confirmation.`, sl.StorageI18n),

plugin/commands/block/snapshot_create.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ func NewSnapshotCreateCommand(sl *metadata.SoftlayerStorageCommand) *SnapshotCre
2929
Short: T("Create a snapshot on a given volume"),
3030
Long: T(`${COMMAND_NAME} sl {{.storageType}} snapshot-create VOLUME_ID [OPTIONS]
3131
32-
Creates a snapshot on a given volume.
33-
3432
EXAMPLE:
3533
${COMMAND_NAME} sl {{.storageType}} snapshot-create 12345678 --note snapshotforibmcloud
3634
This command creates a snapshot for volume with ID 12345678 and with addition note as snapshotforibmcloud.`, sl.StorageI18n),

plugin/commands/block/snapshot_disable.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ func NewSnapshotDisableCommand(sl *metadata.SoftlayerStorageCommand) *SnapshotDi
2828
Short: T("Disable snapshots on the specified schedule for a given volume"),
2929
Long: T(`${COMMAND_NAME} sl {{.storageType}} snapshot-disable VOLUME_ID [OPTIONS]
3030
31-
Disables snapshots on the specified schedule for a given volume.
32-
3331
EXAMPLE:
3432
${COMMAND_NAME} sl {{.storageType}} snapshot-disable 12345678 -s DAILY
3533
This command disables daily snapshot for volume with ID 12345678.`, sl.StorageI18n),

0 commit comments

Comments
 (0)