-
Notifications
You must be signed in to change notification settings - Fork 26
feat(cmd): add --name flag to disambiguate 'agent' shortcut #327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
2a4b502
200debf
b6e5970
f786eee
956e7d8
6648deb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -195,6 +195,131 @@ func TestCreateCommand(t *testing.T) { | |
| createClientMock.AssertCalled(t, "Create", mock.Anything, mock.Anything, mock.Anything, expected) | ||
| }, | ||
| }, | ||
| "creates an app named agent using name flag without triggering shortcut": { | ||
| CmdArgs: []string{"--name", "agent"}, | ||
|
Comment on lines
+198
to
+199
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: Since our intent is for It may also be a good idea to test the agent use-case. The test cases could be:
|
||
| Setup: func(t *testing.T, ctx context.Context, cm *shared.ClientsMock, cf *shared.ClientFactory) { | ||
| // Should prompt for category since agent shortcut is NOT triggered | ||
| cm.IO.On("SelectPrompt", mock.Anything, "Select an app:", mock.Anything, mock.Anything). | ||
| Return( | ||
| iostreams.SelectPromptResponse{ | ||
| Prompt: true, | ||
| Index: 0, // Select starter app | ||
| }, | ||
| nil, | ||
| ) | ||
| cm.IO.On("SelectPrompt", mock.Anything, "Select a language:", mock.Anything, mock.Anything). | ||
| Return( | ||
| iostreams.SelectPromptResponse{ | ||
| Prompt: true, | ||
| Index: 0, // Select Node.js | ||
| }, | ||
| nil, | ||
| ) | ||
| createClientMock = new(CreateClientMock) | ||
| createClientMock.On("Create", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return("", nil) | ||
| CreateFunc = createClientMock.Create | ||
| }, | ||
| ExpectedAsserts: func(t *testing.T, ctx context.Context, cm *shared.ClientsMock) { | ||
| template, err := create.ResolveTemplateURL("slack-samples/bolt-js-starter-template") | ||
| require.NoError(t, err) | ||
| expected := create.CreateArgs{ | ||
| AppName: "agent", | ||
| Template: template, | ||
| } | ||
| createClientMock.AssertCalled(t, "Create", mock.Anything, mock.Anything, mock.Anything, expected) | ||
| // Verify that category prompt WAS called (shortcut was not triggered) | ||
| cm.IO.AssertCalled(t, "SelectPrompt", mock.Anything, "Select an app:", mock.Anything, mock.Anything) | ||
| }, | ||
| }, | ||
| "creates an agent app with name flag overriding positional arg": { | ||
| CmdArgs: []string{"agent", "--name", "my-custom-name"}, | ||
| Setup: func(t *testing.T, ctx context.Context, cm *shared.ClientsMock, cf *shared.ClientFactory) { | ||
| // Should skip category prompt due to agent shortcut | ||
| cm.IO.On("SelectPrompt", mock.Anything, "Select a language:", mock.Anything, mock.Anything). | ||
| Return( | ||
| iostreams.SelectPromptResponse{ | ||
| Prompt: true, | ||
| Index: 0, // Select Node.js | ||
| }, | ||
| nil, | ||
| ) | ||
| createClientMock = new(CreateClientMock) | ||
| createClientMock.On("Create", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return("", nil) | ||
| CreateFunc = createClientMock.Create | ||
| }, | ||
| ExpectedAsserts: func(t *testing.T, ctx context.Context, cm *shared.ClientsMock) { | ||
| template, err := create.ResolveTemplateURL("slack-samples/bolt-js-assistant-template") | ||
| require.NoError(t, err) | ||
| expected := create.CreateArgs{ | ||
| AppName: "my-custom-name", // --name flag overrides | ||
| Template: template, | ||
| } | ||
| createClientMock.AssertCalled(t, "Create", mock.Anything, mock.Anything, mock.Anything, expected) | ||
| // Verify that category prompt was NOT called (shortcut was triggered) | ||
| cm.IO.AssertNotCalled(t, "SelectPrompt", mock.Anything, "Select an app:", mock.Anything, mock.Anything) | ||
| }, | ||
| }, | ||
| "name flag overrides positional app name argument": { | ||
| CmdArgs: []string{"my-project", "--name", "my-name"}, | ||
| Setup: func(t *testing.T, ctx context.Context, cm *shared.ClientsMock, cf *shared.ClientFactory) { | ||
| cm.IO.On("SelectPrompt", mock.Anything, "Select an app:", mock.Anything, mock.Anything). | ||
| Return( | ||
| iostreams.SelectPromptResponse{ | ||
| Prompt: true, | ||
| Index: 0, // Select starter app | ||
| }, | ||
| nil, | ||
| ) | ||
| cm.IO.On("SelectPrompt", mock.Anything, "Select a language:", mock.Anything, mock.Anything). | ||
| Return( | ||
| iostreams.SelectPromptResponse{ | ||
| Prompt: true, | ||
| Index: 0, // Select Node.js | ||
| }, | ||
| nil, | ||
| ) | ||
| createClientMock = new(CreateClientMock) | ||
| createClientMock.On("Create", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return("", nil) | ||
| CreateFunc = createClientMock.Create | ||
| }, | ||
| ExpectedAsserts: func(t *testing.T, ctx context.Context, cm *shared.ClientsMock) { | ||
| template, err := create.ResolveTemplateURL("slack-samples/bolt-js-starter-template") | ||
| require.NoError(t, err) | ||
| expected := create.CreateArgs{ | ||
| AppName: "my-name", // --name flag overrides "my-project" positional arg | ||
| Template: template, | ||
| } | ||
| createClientMock.AssertCalled(t, "Create", mock.Anything, mock.Anything, mock.Anything, expected) | ||
| }, | ||
| }, | ||
| "name flag overrides positional app name argument with agent shortcut": { | ||
| CmdArgs: []string{"agent", "my-project", "--name", "my-name"}, | ||
| Setup: func(t *testing.T, ctx context.Context, cm *shared.ClientsMock, cf *shared.ClientFactory) { | ||
| // Should skip category prompt due to agent shortcut | ||
| cm.IO.On("SelectPrompt", mock.Anything, "Select a language:", mock.Anything, mock.Anything). | ||
| Return( | ||
| iostreams.SelectPromptResponse{ | ||
| Prompt: true, | ||
| Index: 0, // Select Node.js | ||
| }, | ||
| nil, | ||
| ) | ||
| createClientMock = new(CreateClientMock) | ||
| createClientMock.On("Create", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return("", nil) | ||
| CreateFunc = createClientMock.Create | ||
| }, | ||
| ExpectedAsserts: func(t *testing.T, ctx context.Context, cm *shared.ClientsMock) { | ||
| template, err := create.ResolveTemplateURL("slack-samples/bolt-js-assistant-template") | ||
| require.NoError(t, err) | ||
| expected := create.CreateArgs{ | ||
| AppName: "my-name", // --name flag overrides "my-project" positional arg | ||
| Template: template, | ||
| } | ||
| createClientMock.AssertCalled(t, "Create", mock.Anything, mock.Anything, mock.Anything, expected) | ||
| // Verify that category prompt was NOT called (agent shortcut was triggered) | ||
| cm.IO.AssertNotCalled(t, "SelectPrompt", mock.Anything, "Select an app:", mock.Anything, mock.Anything) | ||
| }, | ||
| }, | ||
| }, func(cf *shared.ClientFactory) *cobra.Command { | ||
| return NewCreateCommand(cf) | ||
| }) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
praise: Love the comment calling out that
--name flag overrides any position app name argument.