11package user_test
22
33import (
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