@@ -8,11 +8,11 @@ import (
88 "github.com/UpCloudLtd/upcloud-cli/internal/commands/storage"
99 "github.com/UpCloudLtd/upcloud-cli/internal/config"
1010 smock "github.com/UpCloudLtd/upcloud-cli/internal/mock"
11+ "github.com/UpCloudLtd/upcloud-cli/internal/mockexecute"
1112 internal "github.com/UpCloudLtd/upcloud-cli/internal/service"
1213
1314 "github.com/UpCloudLtd/upcloud-go-api/v4/upcloud"
1415 "github.com/UpCloudLtd/upcloud-go-api/v4/upcloud/request"
15- "github.com/gemalto/flume"
1616 "github.com/stretchr/testify/assert"
1717 "github.com/stretchr/testify/mock"
1818)
@@ -376,15 +376,15 @@ func TestCreateServer(t *testing.T) {
376376 "--title" , "title" ,
377377 "--zone" , "zone" ,
378378 },
379- error : "hostname, zone and some password delivery method are required" ,
379+ error : `required flag(s) "hostname" not set` ,
380380 },
381381 {
382382 name : "zone is missing" ,
383383 args : []string {
384384 "--title" , "title" ,
385385 "--hostname" , "hostname" ,
386386 },
387- error : "hostname, zone and some password delivery method are required" ,
387+ error : `required flag(s) " zone" not set` ,
388388 },
389389 } {
390390 t .Run (test .name , func (t * testing.T ) {
@@ -399,10 +399,9 @@ func TestCreateServer(t *testing.T) {
399399 mService .On ("GetStorages" , mock .Anything ).Return (storages , nil )
400400
401401 c := commands .BuildCommand (testCmd , nil , conf )
402- err := c .Cobra ().Flags ().Parse (test .args )
403- assert .NoError (t , err )
404402
405- _ , err = c .(commands.NoArgumentCommand ).ExecuteWithoutArguments (commands .NewExecutor (conf , mService , flume .New ("test" )))
403+ c .Cobra ().SetArgs (test .args )
404+ _ , err := mockexecute .MockExecute (c , mService , conf )
406405
407406 if test .error != "" {
408407 if err == nil {
0 commit comments