mirror of
https://github.com/planetmint/planetmint-go.git
synced 2025-05-24 15:56:37 +00:00
27 lines
624 B
Go
27 lines
624 B
Go
package cli
|
|
|
|
import (
|
|
"context"
|
|
"planetmint-go/testutil"
|
|
|
|
"github.com/cosmos/cosmos-sdk/client"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
// ExecTestCLICmd builds the client context, mocks the output and executes the command.
|
|
func ExecTestCLICmd(clientCtx client.Context, cmd *cobra.Command, extraArgs []string) (testutil.BufferWriter, error) {
|
|
cmd.SetArgs(extraArgs)
|
|
|
|
_, out := testutil.ApplyMockIO(cmd)
|
|
clientCtx = clientCtx.WithOutput(out)
|
|
|
|
ctx := context.Background()
|
|
ctx = context.WithValue(ctx, client.ClientContextKey, &clientCtx)
|
|
|
|
if err := cmd.ExecuteContext(ctx); err != nil {
|
|
return out, err
|
|
}
|
|
|
|
return out, nil
|
|
}
|