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
3 changes: 3 additions & 0 deletions cmd/app/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ func appSettingsCommandRunE(clients *shared.ClientFactory, cmd *cobra.Command, a
if err != nil {
// If no apps exist, open the list of all apps known to the developer
if slackerror.Is(err, slackerror.ErrInstallationRequired) {
// Clean up any empty .slack directory and files created during app selection
clients.AppClient().CleanUp()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 note: Another approach might check first if this command was run outside of a project before prompting. I'm open to either change, but wanted to be more concise to start.


host := clients.API().Host()
parsed, err := url.Parse(host)
if err != nil {
Expand Down
9 changes: 8 additions & 1 deletion cmd/app/settings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,26 @@ package app

import (
"context"
"path/filepath"
"testing"

"github.com/slackapi/slack-cli/internal/app"
"github.com/slackapi/slack-cli/internal/config"
"github.com/slackapi/slack-cli/internal/prompts"
"github.com/slackapi/slack-cli/internal/shared"
"github.com/slackapi/slack-cli/internal/shared/types"
"github.com/slackapi/slack-cli/internal/slackdeps"
"github.com/slackapi/slack-cli/internal/slackerror"
"github.com/slackapi/slack-cli/internal/slacktrace"
"github.com/slackapi/slack-cli/test/testutil"
"github.com/spf13/cobra"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
)

func Test_App_SettingsCommand(t *testing.T) {
testutil.TableTestCommand(t, testutil.CommandTests{
"opens app listing page when not in a project directory": {
"opens app listing page when run from a random directory": {
Setup: func(t *testing.T, ctx context.Context, cm *shared.ClientsMock, cf *shared.ClientFactory) {
appSelectMock := prompts.NewAppSelectMock()
appSelectMock.On(
Expand All @@ -53,6 +56,10 @@ func Test_App_SettingsCommand(t *testing.T) {
cm.Browser.AssertCalled(t, "OpenURL", expectedURL)
cm.IO.AssertCalled(t, "PrintTrace", mock.Anything, slacktrace.AppSettingsStart, mock.Anything)
cm.IO.AssertCalled(t, "PrintTrace", mock.Anything, slacktrace.AppSettingsSuccess, []string{expectedURL})
// Verify no .slack directory was left behind
slackDir := filepath.Join(slackdeps.MockWorkingDirectory, ".slack")
_, err := cm.Fs.Stat(slackDir)
assert.True(t, cm.Os.IsNotExist(err), ".slack directory should not exist")
},
},
"errors for rosi applications": {
Expand Down
Loading