Skip to content

Commit 90ce416

Browse files
Ramkishor ChaladiRamkishor Chaladi
authored andcommitted
updated the code
1 parent 54c1c56 commit 90ce416

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

plugin/commands/user/vpn_enable.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func (cmd *VpnEnableCommand) Run(args []string) error {
4848
}
4949
success, err := cmd.UserManager.EditUser(userTemplate, userID)
5050
if err != nil {
51-
return slErrors.NewAPIError(T("Error: "), err.Error(), 2)
51+
return slErrors.NewAPIError(T(""), err.Error(), 2)
5252
}
5353
if success {
5454
cmd.UI.Ok()

plugin/commands/user/vpn_enable_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
package user_test
22

33
import (
4+
"errors"
5+
46
"github.com/IBM-Cloud/ibm-cloud-cli-sdk/testhelpers/terminal"
57
. "github.com/onsi/ginkgo"
68
. "github.com/onsi/gomega"
9+
"github.com/softlayer/softlayer-go/datatypes"
710
"github.com/softlayer/softlayer-go/session"
11+
"github.com/softlayer/softlayer-go/sl"
812

913
"github.ibm.com/SoftLayer/softlayer-cli/plugin/commands/user"
1014
"github.ibm.com/SoftLayer/softlayer-cli/plugin/metadata"
@@ -27,6 +31,10 @@ var _ = Describe("user vpn-enable", func() {
2731
cliCommand = user.NewVpnEnableCommand(slCommand)
2832
cliCommand.Command.PersistentFlags().Var(cliCommand.OutputFlag, "output", "--output=JSON for json output.")
2933
cliCommand.UserManager = fakeUserManager
34+
35+
testUser = datatypes.User_Customer{
36+
SslVpnAllowedFlag: sl.Bool(true),
37+
}
3038
})
3139

3240
Describe("user vpn-enable", func() {
@@ -44,5 +52,25 @@ var _ = Describe("user vpn-enable", func() {
4452
Expect(err.Error()).To(ContainSubstring("Invalid input for 'User ID'. It must be a positive integer."))
4553
})
4654
})
55+
56+
Context("Account cancel-item, softlayer errors", func() {
57+
It("Set command with unknow item ID", func() {
58+
fakeUserManager.EditUserReturns(true, errors.New("SoftLayer_Exception_ObjectNotFound: Unable to find object with id of '123'. (HTTP 404)"))
59+
err := testhelpers.RunCobraCommand(cliCommand.Command, "123")
60+
Expect(err).To(HaveOccurred())
61+
Expect(err.Error()).To(ContainSubstring("SoftLayer_Exception_ObjectNotFound: Unable to find object with id of '123'. (HTTP 404)"))
62+
})
63+
})
64+
65+
Context("Return no error", func() {
66+
BeforeEach(func() {
67+
fakeUserManager.EditUserReturns(true, nil)
68+
})
69+
It("enable", func() {
70+
err := testhelpers.RunCobraCommand(cliCommand.Command, "111111")
71+
Expect(err).NotTo(HaveOccurred())
72+
Expect(fakeUI.Outputs()).To(ContainSubstring("OK"))
73+
})
74+
})
4775
})
4876
})

0 commit comments

Comments
 (0)