-
Notifications
You must be signed in to change notification settings - Fork 363
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
do not parse flags separately from args in plugin cmd (#846)
* do not parse flags separately from args in plugin cmd * remove print from plugin cmd test * goimports-ed with -local
- Loading branch information
1 parent
0638c6a
commit 88ac6a3
Showing
2 changed files
with
51 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package cmd | ||
|
||
import ( | ||
"context" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/stripe/stripe-cli/pkg/plugins" | ||
) | ||
|
||
func createPluginCmd() *pluginTemplateCmd { | ||
plugin := plugins.Plugin{ | ||
Shortname: "test", | ||
Shortdesc: "test your stuff", | ||
Binary: "stripe-cli-test", | ||
MagicCookieValue: "magic", | ||
Releases: []plugins.Release{{ | ||
Arch: "amd64", | ||
OS: "darwin", | ||
Version: "0.0.1", | ||
Sum: "c53a98c3fa63563227eb8b5601acedb5e0e70fed2e1d52a5918a17ac755f17f7", | ||
}}, | ||
} | ||
|
||
pluginCmd := newPluginTemplateCmd(&Config, &plugin) | ||
|
||
return pluginCmd | ||
} | ||
|
||
func TestFlagsArePassedAsArgs(t *testing.T) { | ||
Execute(context.Background()) | ||
|
||
pluginCmd := createPluginCmd() | ||
rootCmd.AddCommand(pluginCmd.cmd) | ||
executeCommandC(rootCmd, "test", "testarg", "--testflag") | ||
|
||
require.Equal(t, len(pluginCmd.ParsedArgs), 2) | ||
require.Equal(t, strings.Join(pluginCmd.ParsedArgs, " "), "testarg --testflag") | ||
} |