11package database
22
33import (
4- "bytes"
54 "strings"
65 "testing"
76
87 "github.com/UpCloudLtd/upcloud-cli/internal/commands"
98 "github.com/UpCloudLtd/upcloud-cli/internal/config"
109 smock "github.com/UpCloudLtd/upcloud-cli/internal/mock"
11- "github.com/UpCloudLtd/upcloud-cli/internal/output "
10+ "github.com/UpCloudLtd/upcloud-cli/internal/mockexecute "
1211
1312 "github.com/UpCloudLtd/upcloud-go-api/v4/upcloud"
14- "github.com/gemalto/flume"
1513 "github.com/jedib0t/go-pretty/v6/text"
1614 "github.com/stretchr/testify/assert"
1715 "github.com/stretchr/testify/mock"
@@ -38,16 +36,10 @@ func TestDatabasePlans_SortedHumanOutput(t *testing.T) {
3836
3937 command := commands .BuildCommand (PlansCommand (), nil , conf )
4038
41- res , err := command .(commands.MultipleArgumentCommand ).Execute (commands .NewExecutor (conf , & mService , flume .New ("test" )), "pg" )
42-
43- assert .Nil (t , err )
44-
45- buf := bytes .NewBuffer (nil )
46- err = output .Render (buf , conf , res )
47- output := buf .String ()
39+ command .Cobra ().SetArgs ([]string {"pg" })
40+ output , err := mockexecute .MockExecute (command , & mService , conf )
4841
4942 assert .NoError (t , err )
50-
5143 assert .Less (t , strings .Index (output , "test-plan-1" ), strings .Index (output , "test-plan-2" ))
5244 assert .Less (t , strings .Index (output , "test-plan-2" ), strings .Index (output , "test-plan-3" ))
5345 assert .Less (t , strings .Index (output , "test-plan-3" ), strings .Index (output , "test-plan-4" ))
0 commit comments