11package file_test
22
33import (
4- "errors"
5-
64 "github.com/IBM-Cloud/ibm-cloud-cli-sdk/testhelpers/terminal"
75 . "github.com/onsi/ginkgo"
86 . "github.com/onsi/gomega"
97
10- "github.com/softlayer/softlayer-go/datatypes"
118 "github.com/softlayer/softlayer-go/session"
12- "github.com/softlayer/softlayer-go/sl"
139 "github.ibm.com/SoftLayer/softlayer-cli/plugin/commands/file"
1410 "github.ibm.com/SoftLayer/softlayer-cli/plugin/metadata"
1511 "github.ibm.com/SoftLayer/softlayer-cli/plugin/testhelpers"
@@ -19,18 +15,18 @@ var _ = Describe("Volume detail", func() {
1915 var (
2016 fakeUI * terminal.FakeUI
2117 cliCommand * file.VolumeDetailCommand
22- fakeSession * session.Session
18+ fakeSession * session.Session
19+ fakeHandler * testhelpers.FakeTransportHandler
2320 slCommand * metadata.SoftlayerStorageCommand
24- FakeStorageManager * testhelpers. FakeStorageManager
21+
2522 )
2623 BeforeEach (func () {
2724 fakeUI = terminal .NewFakeUI ()
28- fakeSession = testhelpers .NewFakeSoftlayerSession ([] string {} )
29- FakeStorageManager = new ( testhelpers.FakeStorageManager )
25+ fakeSession = testhelpers .NewFakeSoftlayerSession (nil )
26+ fakeHandler = testhelpers .GetSessionHandler ( fakeSession )
3027 slCommand = metadata .NewSoftlayerStorageCommand (fakeUI , fakeSession , "file" )
3128 cliCommand = file .NewVolumeDetailCommand (slCommand )
3229 cliCommand .Command .PersistentFlags ().Var (cliCommand .OutputFlag , "output" , "--output=JSON for json output." )
33- cliCommand .StorageManager = FakeStorageManager
3430 })
3531
3632 Describe ("Volume detail" , func () {
@@ -51,7 +47,7 @@ var _ = Describe("Volume detail", func() {
5147
5248 Context ("Volume detail with correct volume id but server API call fails" , func () {
5349 BeforeEach (func () {
54- FakeStorageManager . GetVolumeDetailsReturns (datatypes. Network_Storage {}, errors . New ( " Internal Server Error") )
50+ fakeHandler . AddApiError ( "SoftLayer_Network_Storage" , "getObject" , 500 , " Internal Server Error" )
5551 })
5652 It ("return error" , func () {
5753 err := testhelpers .RunCobraCommand (cliCommand .Command , "1234" )
@@ -62,63 +58,14 @@ var _ = Describe("Volume detail", func() {
6258 })
6359
6460 Context ("Volume detail with correct volume id" , func () {
65- BeforeEach (func () {
66- FakeStorageManager .GetVolumeDetailsReturns (datatypes.Network_Storage {
67- Id : sl .Int (1234 ),
68- Username : sl .String ("myvolume" ),
69- CapacityGb : sl .Int (1000 ),
70- Iops : sl .String ("400" ),
71- StorageTierLevel : sl .String ("HEAVY_WRITE" ),
72- StorageType : & datatypes.Network_Storage_Type {
73- KeyName : sl .String ("performance" ),
74- },
75- ServiceResource : & datatypes.Network_Service_Resource {
76- Datacenter : & datatypes.Location {
77- Name : sl .String ("tok02" ),
78- },
79- },
80- ServiceResourceBackendIpAddress : sl .String ("9.9.9.9" ),
81- SnapshotCapacityGb : sl .String ("500" ),
82- ParentVolume : & datatypes.Network_Storage {
83- SnapshotSizeBytes : sl .String ("10000" ),
84- },
85- ActiveTransactionCount : sl .Uint (uint (1 )),
86- ActiveTransactions : []datatypes.Provisioning_Version1_Transaction {
87- datatypes.Provisioning_Version1_Transaction {
88- TransactionStatus : & datatypes.Provisioning_Version1_Transaction_Status {
89- FriendlyName : sl .String ("Restarting" ),
90- },
91- },
92- },
93- ReplicationPartnerCount : sl .Uint (uint (1 )),
94- ReplicationStatus : sl .String ("replication finished" ),
95- ReplicationPartners : []datatypes.Network_Storage {
96- datatypes.Network_Storage {
97- Id : sl .Int (5678 ),
98- Username : sl .String ("myreplicant" ),
99- ServiceResourceBackendIpAddress : sl .String ("9.9.9.8" ),
100- ServiceResource : & datatypes.Network_Service_Resource {
101- Datacenter : & datatypes.Location {
102- Name : sl .String ("dal10" ),
103- },
104- },
105- ReplicationSchedule : & datatypes.Network_Storage_Schedule {
106- Type : & datatypes.Network_Storage_Schedule_Type {
107- Keyname : sl .String ("DAILY" ),
108- },
109- },
110- },
111- },
112- }, nil )
113- })
11461 It ("return no error" , func () {
11562 err := testhelpers .RunCobraCommand (cliCommand .Command , "1234" )
11663 Expect (err ).NotTo (HaveOccurred ())
117- Expect (fakeUI .Outputs ()).To (ContainSubstring ("1234 " ))
118- Expect (fakeUI .Outputs ()).To (ContainSubstring ("myvolume " ))
119- Expect (fakeUI .Outputs ()).To (ContainSubstring ("tok02 " ))
120- Expect (fakeUI .Outputs ()).To (ContainSubstring ("9.9.9.9 " ))
121- Expect (fakeUI .Outputs ()).To (ContainSubstring ("Restarting " ))
64+ Expect (fakeUI .Outputs ()).To (ContainSubstring ("ID 17336531 " ))
65+ Expect (fakeUI .Outputs ()).To (ContainSubstring ("User name IBM01SEL278444-16 " ))
66+ Expect (fakeUI .Outputs ()).To (ContainSubstring ("Endurance Tier WRITEHEAVY_TIER " ))
67+ Expect (fakeUI .Outputs ()).To (ContainSubstring ("Notes - " ))
68+ Expect (fakeUI .Outputs ()).To (ContainSubstring ("Encrypted False " ))
12269 })
12370 })
12471 })
0 commit comments