@@ -2,9 +2,7 @@ package block_test
22
33import (
44 "errors"
5- "strings"
65
7- . "github.com/IBM-Cloud/ibm-cloud-cli-sdk/testhelpers/matchers"
86 "github.com/IBM-Cloud/ibm-cloud-cli-sdk/testhelpers/terminal"
97 . "github.com/onsi/ginkgo/v2"
108 . "github.com/onsi/gomega"
@@ -36,21 +34,15 @@ var _ = Describe("Access Revoke", func() {
3634 cliCommand .Command .PersistentFlags ().Var (cliCommand .OutputFlag , "output" , "--output=JSON for json output." )
3735 cliCommand .StorageManager = FakeStorageManager
3836 cliCommand .NetworkManager = fakeNetworkManager
37+ FakeStorageManager .GetVolumeIdReturns (1234 , nil )
3938 })
4039
4140 Describe ("Access Revoke" , func () {
4241 Context ("Access revoke without volume id" , func () {
4342 It ("return error" , func () {
4443 err := testhelpers .RunCobraCommand (cliCommand .Command )
4544 Expect (err ).To (HaveOccurred ())
46- Expect (strings .Contains (err .Error (), "Incorrect Usage: This command requires one argument" )).To (BeTrue ())
47- })
48- })
49- Context ("Access revoke with wrong volume id" , func () {
50- It ("error resolving volume ID" , func () {
51- err := testhelpers .RunCobraCommand (cliCommand .Command , "abc" )
52- Expect (err ).To (HaveOccurred ())
53- Expect (strings .Contains (err .Error (), "Invalid input for 'Volume ID'. It must be a positive integer." )).To (BeTrue ())
45+ Expect (err .Error ()).To (ContainSubstring ("Incorrect Usage: This command requires one argument" ))
5446 })
5547 })
5648
@@ -61,8 +53,7 @@ var _ = Describe("Access Revoke", func() {
6153 It ("return no error" , func () {
6254 err := testhelpers .RunCobraCommand (cliCommand .Command , "1234" , "--virtual-id" , "5678" )
6355 Expect (err ).NotTo (HaveOccurred ())
64- Expect (fakeUI .Outputs ()).To (ContainSubstrings ([]string {"OK" }))
65- Expect (fakeUI .Outputs ()).To (ContainSubstrings ([]string {"Access to 1234 was revoked for virtual server 5678" }))
56+ Expect (fakeUI .Outputs ()).To (ContainSubstring ("Access to 1234 was revoked for virtual server 5678" ))
6657 })
6758 })
6859
@@ -73,8 +64,7 @@ var _ = Describe("Access Revoke", func() {
7364 It ("return no error" , func () {
7465 err := testhelpers .RunCobraCommand (cliCommand .Command , "1234" , "--hardware-id" , "5678" )
7566 Expect (err ).NotTo (HaveOccurred ())
76- Expect (fakeUI .Outputs ()).To (ContainSubstrings ([]string {"OK" }))
77- Expect (fakeUI .Outputs ()).To (ContainSubstrings ([]string {"Access to 1234 was revoked for hardware server 5678." }))
67+ Expect (fakeUI .Outputs ()).To (ContainSubstring ("Access to 1234 was revoked for hardware server 5678." ))
7868 })
7969 })
8070
@@ -85,8 +75,7 @@ var _ = Describe("Access Revoke", func() {
8575 It ("return no error" , func () {
8676 err := testhelpers .RunCobraCommand (cliCommand .Command , "1234" , "--ip-address-id" , "5678" )
8777 Expect (err ).NotTo (HaveOccurred ())
88- Expect (fakeUI .Outputs ()).To (ContainSubstrings ([]string {"OK" }))
89- Expect (fakeUI .Outputs ()).To (ContainSubstrings ([]string {"Access to 1234 was revoked for IP address 5678." }))
78+ Expect (fakeUI .Outputs ()).To (ContainSubstring ("Access to 1234 was revoked for IP address 5678." ))
9079 })
9180 })
9281
@@ -98,8 +87,7 @@ var _ = Describe("Access Revoke", func() {
9887 It ("return no error" , func () {
9988 err := testhelpers .RunCobraCommand (cliCommand .Command , "1234" , "--ip-address" , "1.2.3.4" )
10089 Expect (err ).NotTo (HaveOccurred ())
101- Expect (fakeUI .Outputs ()).To (ContainSubstrings ([]string {"OK" }))
102- Expect (fakeUI .Outputs ()).To (ContainSubstrings ([]string {"Access to 1234 was revoked for IP address 5678." }))
90+ Expect (fakeUI .Outputs ()).To (ContainSubstring ("Access to 1234 was revoked for IP address 5678." ))
10391 })
10492 })
10593
@@ -111,22 +99,23 @@ var _ = Describe("Access Revoke", func() {
11199 It ("return error" , func () {
112100 err := testhelpers .RunCobraCommand (cliCommand .Command , "1234" , "--ip-address" , "1.2.3.4" )
113101 Expect (err ).To (HaveOccurred ())
114- Expect (fakeUI .Outputs ()).NotTo (ContainSubstrings ([]string {"OK" }))
115- Expect (strings .Contains (err .Error (), "IP address 1.2.3.4 is not found on your account.Please confirm IP and try again." )).To (BeTrue ())
116- Expect (strings .Contains (err .Error (), "Not Found" )).To (BeTrue ())
102+ Expect (err .Error ()).To (ContainSubstring ("IP address 1.2.3.4 is not found on your account.Please confirm IP and try again." ))
103+ Expect (err .Error ()).To (ContainSubstring ("Not Found" ))
117104 })
118105 })
119106
120107 Context ("Access Authorize with correct volume id but server API call fails" , func () {
121108 BeforeEach (func () {
122- FakeStorageManager .DeauthorizeHostToVolumeReturns ([]datatypes.Network_Storage_Allowed_Host {}, errors .New ("Internal Server Error" ))
109+ FakeStorageManager .DeauthorizeHostToVolumeReturns (
110+ []datatypes.Network_Storage_Allowed_Host {},
111+ errors .New ("Internal Server Error" ),
112+ )
123113 })
124114 It ("return error" , func () {
125115 err := testhelpers .RunCobraCommand (cliCommand .Command , "1234" , "--virtual-id" , "5678" )
126116 Expect (err ).To (HaveOccurred ())
127- Expect (fakeUI .Outputs ()).NotTo (ContainSubstrings ([]string {"OK" }))
128- Expect (strings .Contains (err .Error (), "Failed to revoke access to volume 1234." )).To (BeTrue ())
129- Expect (strings .Contains (err .Error (), "Internal Server Error" )).To (BeTrue ())
117+ Expect (err .Error ()).To (ContainSubstring ("Failed to revoke access to volume 1234." ))
118+ Expect (err .Error ()).To (ContainSubstring ("Internal Server Error" ))
130119 })
131120 })
132121 })
0 commit comments