@@ -230,3 +230,46 @@ func TestModifyCommandExistingBackupRule(t *testing.T) {
230230 })
231231 }
232232}
233+
234+ func TestModifyCommandAutoresize (t * testing.T ) {
235+ t .Run ("modifying storage size with filesystem autoresize enabled" , func (t * testing.T ) {
236+ conf := config .New ()
237+ testCmd := ModifyCommand ()
238+ mService := new (smock.Service )
239+ UUID := "some_storage_id"
240+
241+ mGetDetailsResponse := upcloud.StorageDetails {
242+ Storage : upcloud.Storage {Size : 45 },
243+ BackupRule : & upcloud.BackupRule {},
244+ }
245+
246+ mModifyResponse := upcloud.StorageDetails {
247+ Storage : upcloud.Storage {
248+ Size : 50 ,
249+ },
250+ }
251+
252+ mResizeResponse := upcloud.ResizeStorageFilesystemBackup {
253+ UUID : "resize_backup" ,
254+ }
255+
256+ conf .Service = internal.Wrapper {Service : mService }
257+ mService .On ("ModifyStorage" , & request.ModifyStorageRequest {UUID : UUID , Size : 50 }).Return (& mModifyResponse , nil )
258+ mService .On ("ResizeStorageFilesystem" , & request.ResizeStorageFilesystemRequest {UUID : UUID }).Return (& mResizeResponse , nil )
259+ mService .On ("GetStorageDetails" , & request.GetStorageDetailsRequest {UUID : UUID }).Return (& mGetDetailsResponse , nil )
260+
261+ c := commands .BuildCommand (testCmd , nil , conf )
262+ err := c .Cobra ().Flags ().Parse ([]string {"--size" , "50" , "--enable-filesystem-autoresize" })
263+ assert .NoError (t , err )
264+
265+ output , err := c .(commands.MultipleArgumentCommand ).Execute (commands .NewExecutor (conf , mService , flume .New ("test" )), UUID )
266+ assert .NoError (t , err )
267+ mService .AssertNumberOfCalls (t , "ModifyStorage" , 1 )
268+ mService .AssertNumberOfCalls (t , "ResizeStorageFilesystem" , 1 )
269+
270+ json , err := output .MarshalJSON ()
271+ assert .NoError (t , err )
272+ assert .Contains (t , string (json ), "latest_resize_backup" )
273+ assert .Contains (t , string (json ), "resize_backup" )
274+ })
275+ }
0 commit comments