@@ -22,82 +22,75 @@ var _ = Describe("virtual storage", func() {
2222 fakeSession * session.Session
2323 slCommand * metadata.SoftlayerCommand
2424 fakeVSManager * testhelpers.FakeVirtualServerManager
25+ fakeHandler * testhelpers.FakeTransportHandler
2526 )
2627 BeforeEach (func () {
2728 fakeUI = terminal .NewFakeUI ()
28- fakeSession = testhelpers .NewFakeSoftlayerSession ([]string {})
29+ fakeSession = testhelpers .NewFakeSoftlayerSession (nil )
30+ fakeHandler = testhelpers .GetSessionHandler (fakeSession )
2931 fakeVSManager = new (testhelpers.FakeVirtualServerManager )
3032 slCommand = metadata .NewSoftlayerCommand (fakeUI , fakeSession )
3133 cliCommand = virtual .NewStorageCommand (slCommand )
3234 cliCommand .Command .PersistentFlags ().Var (cliCommand .OutputFlag , "output" , "--output=JSON for json output." )
33- cliCommand .VirtualServerManager = fakeVSManager
35+
36+ })
37+
38+ AfterEach (func () {
39+ // Clear API call logs and any errors that might have been set after every test
40+ fakeHandler .ClearApiCallLogs ()
41+ fakeHandler .ClearErrors ()
3442 })
3543
3644 Describe ("virtual storage" , func () {
37- Context ("virtual storage without id" , func () {
45+ BeforeEach (func () {
46+ cliCommand .VirtualServerManager = fakeVSManager
47+ })
48+ Context ("User Input Checks" , func () {
3849 It ("return error" , func () {
3950 err := testhelpers .RunCobraCommand (cliCommand .Command )
4051 Expect (err ).To (HaveOccurred ())
4152 Expect (err .Error ()).To (ContainSubstring ("Incorrect Usage: This command requires one argument" ))
4253 })
43- })
44-
45- Context ("virtual storage with wrong id" , func () {
4654 It ("return error" , func () {
4755 err := testhelpers .RunCobraCommand (cliCommand .Command , "abcd" )
4856 Expect (err ).To (HaveOccurred ())
4957 Expect (err .Error ()).To (ContainSubstring ("Invalid input for 'Virtual server ID'. It must be a positive integer." ))
5058 })
5159 })
5260
53- Context ("virtual storage ISCSI with server fails " , func () {
54- BeforeEach ( func () {
61+ Context ("API Errors " , func () {
62+ It ( "Failed to get ISCSI Storage" , func () {
5563 fakeVSManager .GetStorageDetailsReturns ([]datatypes.Network_Storage {}, errors .New ("Internal server error" ))
56- })
57- It ("return error" , func () {
5864 err := testhelpers .RunCobraCommand (cliCommand .Command , "1234" )
5965 Expect (err ).To (HaveOccurred ())
6066 Expect (err .Error ()).To (ContainSubstring ("Failed to get iscsi storage detail for the virtual server 1234." ))
6167 Expect (err .Error ()).To (ContainSubstring ("Internal server error" ))
6268 })
63- })
64-
65- Context ("virtual storage credentials with server fails" , func () {
66- BeforeEach (func () {
69+ It ("virtual storage credentials with server fails" , func () {
6770 fakeVSManager .GetStorageCredentialsReturns (datatypes.Network_Storage_Allowed_Host {}, errors .New ("Internal server error" ))
68- })
69- It ("return error" , func () {
7071 err := testhelpers .RunCobraCommand (cliCommand .Command , "1234" )
7172 Expect (err ).To (HaveOccurred ())
7273 Expect (err .Error ()).To (ContainSubstring ("Failed to get the storage credential detail for the virtual server 1234." ))
7374 Expect (err .Error ()).To (ContainSubstring ("Internal server error" ))
7475 })
75- })
76-
77- Context ("virtual portable storage with server fails" , func () {
78- BeforeEach (func () {
76+ It ("virtual portable storage with server fails" , func () {
7977 fakeVSManager .GetPortableStorageReturns ([]datatypes.Virtual_Disk_Image {}, errors .New ("Internal server error" ))
80- })
81- It ("return error" , func () {
8278 err := testhelpers .RunCobraCommand (cliCommand .Command , "1234" )
8379 Expect (err ).To (HaveOccurred ())
8480 Expect (err .Error ()).To (ContainSubstring ("Failed to get the portable storage detail for the virtual server 1234." ))
8581 Expect (err .Error ()).To (ContainSubstring ("Internal server error" ))
8682 })
87- })
88-
89- Context ("virtual local disks with server fails" , func () {
90- BeforeEach (func () {
83+ It ("virtual local disks with server fails" , func () {
9184 fakeVSManager .GetLocalDisksReturns ([]datatypes.Virtual_Guest_Block_Device {}, errors .New ("Internal server error" ))
92- })
93- It ("return error" , func () {
9485 err := testhelpers .RunCobraCommand (cliCommand .Command , "1234" )
9586 Expect (err ).To (HaveOccurred ())
9687 Expect (err .Error ()).To (ContainSubstring ("Failed to get the local disks detail for the virtual server 1234." ))
9788 Expect (err .Error ()).To (ContainSubstring ("Internal server error" ))
9889 })
90+
9991 })
10092
93+
10194 Context ("hardware iscsi" , func () {
10295 BeforeEach (func () {
10396 fakeVSManager .GetStorageDetailsReturns ([]datatypes.Network_Storage {
@@ -196,4 +189,14 @@ var _ = Describe("virtual storage", func() {
196189 })
197190 })
198191 })
192+ Describe ("virtual storage with fixtures" , func () {
193+ Context ("Issues943" , func () {
194+ It ("Successful" , func () {
195+ err := testhelpers .RunCobraCommand (cliCommand .Command , "934" )
196+ Expect (err ).NotTo (HaveOccurred ())
197+ Expect (fakeUI .Outputs ()).To (ContainSubstring ("Disk" ))
198+ })
199+ })
200+ })
201+
199202})
0 commit comments