Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions cmd/platform/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,16 +316,13 @@ func printDeployHostingCompletion(clients *shared.ClientFactory, cmd *cobra.Comm
func errorMissingDeployHook(clients *shared.ClientFactory) error {
if !clients.SDKConfig.Hooks.Deploy.IsAvailable() {
return slackerror.New(slackerror.ErrSDKHookNotFound).
WithMessage("Missing the `deploy` hook from the `%s` file", config.GetProjectHooksJSONFilePath()).
WithMessage("No deploy script found").
WithRemediation("%s", strings.Join([]string{
"Provide a command or script to run with the deploy command by adding a new hook.",
"For deployment options, see:",
" https://docs.slack.dev/tools/slack-cli/reference/hooks/#deploy",
"",
fmt.Sprintf("Example `%s` `deploy` hook:", config.GetProjectHooksJSONFilePath()),
"{",
` "hooks": {`,
` "deploy": "./deploy.sh"`,
" }",
"}",
"To start a local development server, use:",
fmt.Sprintf(" %s", style.Commandf("run", false)),
}, "\n"))
}
return nil
Expand Down
33 changes: 20 additions & 13 deletions cmd/platform/deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,14 @@ func TestDeployCommand(t *testing.T) {

func TestDeployCommand_HasValidDeploymentMethod(t *testing.T) {
tests := map[string]struct {
app types.App
manifest types.SlackYaml
manifestError error
manifestSource config.ManifestSource
deployScript string
expectedError error
app types.App
manifest types.SlackYaml
manifestError error
manifestSource config.ManifestSource
deployScript string
expectedError error
expectedMessage string
expectedRemediation []string
}{
"fails when no manifest exists": {
manifestError: slackerror.New(slackerror.ErrInvalidManifest),
Expand All @@ -142,8 +144,10 @@ func TestDeployCommand_HasValidDeploymentMethod(t *testing.T) {
deployScript: "sleep 4",
},
"fails if no deploy hook is provided": {
manifestSource: config.ManifestSourceLocal,
expectedError: slackerror.New(slackerror.ErrSDKHookNotFound),
manifestSource: config.ManifestSourceLocal,
expectedError: slackerror.New(slackerror.ErrSDKHookNotFound),
expectedMessage: "No deploy script found",
expectedRemediation: []string{"https://docs.slack.dev/tools/slack-cli/reference/hooks/#deploy", "run"},
},
"succeeds if the app exists and the manifest source is remote": {
app: types.App{
Expand Down Expand Up @@ -183,11 +187,14 @@ func TestDeployCommand_HasValidDeploymentMethod(t *testing.T) {
err := hasValidDeploymentMethod(ctx, clients, app, types.SlackAuth{})
if tc.expectedError != nil {
require.Error(t, err)
assert.Equal(
t,
slackerror.ToSlackError(tc.expectedError).Code,
slackerror.ToSlackError(err).Code,
)
slackErr := slackerror.ToSlackError(err)
assert.Equal(t, slackerror.ToSlackError(tc.expectedError).Code, slackErr.Code)
if tc.expectedMessage != "" {
assert.Contains(t, slackErr.Message, tc.expectedMessage)
}
for _, r := range tc.expectedRemediation {
assert.Contains(t, slackErr.Remediation, r)
}
} else {
require.NoError(t, err)
}
Expand Down
Loading