Skip to content

Commit 315c9bb

Browse files
committed
simplify redundant tests
1 parent 8128d5e commit 315c9bb

1 file changed

Lines changed: 0 additions & 47 deletions

File tree

cmd/project/create_test.go

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,14 @@ package project
1616

1717
import (
1818
"context"
19-
"os"
20-
"path/filepath"
2119
"testing"
2220

23-
"github.com/slackapi/slack-cli/internal/api"
24-
"github.com/slackapi/slack-cli/internal/app"
2521
"github.com/slackapi/slack-cli/internal/config"
2622
"github.com/slackapi/slack-cli/internal/iostreams"
2723
"github.com/slackapi/slack-cli/internal/pkg/create"
2824
"github.com/slackapi/slack-cli/internal/shared"
29-
"github.com/slackapi/slack-cli/internal/shared/types"
3025
"github.com/slackapi/slack-cli/internal/slackerror"
3126
"github.com/slackapi/slack-cli/test/testutil"
32-
"github.com/spf13/afero"
3327
"github.com/spf13/cobra"
3428
"github.com/stretchr/testify/assert"
3529
"github.com/stretchr/testify/mock"
@@ -886,47 +880,6 @@ func TestCreateCommand_AppFlag(t *testing.T) {
886880
createClientMock.AssertNotCalled(t, "Create", mock.Anything, mock.Anything, mock.Anything)
887881
},
888882
},
889-
"app flag with template creates project then runs link": {
890-
CmdArgs: []string{"my-app", "--template", "slack-samples/bolt-js-starter-template", "--app", "A0123456789", "--environment", "local"},
891-
Setup: func(t *testing.T, ctx context.Context, cm *shared.ClientsMock, cf *shared.ClientFactory) {
892-
cm.IO.On("SelectPrompt", mock.Anything, mock.Anything, mock.Anything, mock.Anything).
893-
Return(iostreams.SelectPromptResponse{Flag: true, Option: "slack-samples/bolt-js-starter-template"}, nil).Maybe()
894-
895-
// LinkExistingApp calls PromptTeamSlackAuth which calls Auths
896-
cm.Auth.On("Auths", mock.Anything).Return([]types.SlackAuth{
897-
{Token: "xoxp-test-token", TeamID: "T123", TeamDomain: "test-team", UserID: "U123"},
898-
}, nil)
899-
// LinkExistingApp validates app access
900-
cm.API.On("GetAppStatus", mock.Anything, "xoxp-test-token", []string{"A0123456789"}, "T123").
901-
Return(api.GetAppStatusResult{}, nil)
902-
903-
// LinkExistingApp calls saveAppToJSON
904-
appClientMock := &app.AppClientMock{}
905-
appClientMock.On("GetDeployed", mock.Anything, "T123").Return(types.NewApp(), nil)
906-
appClientMock.On("GetLocal", mock.Anything, "T123").Return(types.NewApp(), nil)
907-
appClientMock.On("SaveLocal", mock.Anything, mock.Anything).Return(nil)
908-
cf.AppClient().AppClientInterface = appClientMock
909-
910-
// Create project directory on real filesystem for os.Chdir
911-
tmpDir := t.TempDir()
912-
projectDir := filepath.Join(tmpDir, "my-app")
913-
require.NoError(t, os.MkdirAll(projectDir, 0755))
914-
915-
// Set up mock Os.Getwd to return the project dir (used by ProjectConfig)
916-
cm.Os.On("Getwd").Return(projectDir, nil)
917-
// Create .slack/hooks.json on mock filesystem so GetProjectDirPath succeeds
918-
require.NoError(t, cm.Fs.MkdirAll(filepath.Join(projectDir, ".slack"), 0755))
919-
require.NoError(t, afero.WriteFile(cm.Fs, filepath.Join(projectDir, ".slack", "hooks.json"), []byte("{}"), 0644))
920-
921-
createClientMock = new(CreateClientMock)
922-
createClientMock.On("Create", mock.Anything, mock.Anything, mock.Anything).Return(projectDir, nil)
923-
CreateFunc = createClientMock.Create
924-
},
925-
ExpectedAsserts: func(t *testing.T, ctx context.Context, cm *shared.ClientsMock) {
926-
createClientMock.AssertCalled(t, "Create", mock.Anything, mock.Anything, mock.Anything)
927-
cm.API.AssertCalled(t, "GetAppStatus", mock.Anything, "xoxp-test-token", []string{"A0123456789"}, "T123")
928-
},
929-
},
930883
}, func(cf *shared.ClientFactory) *cobra.Command {
931884
return NewCreateCommand(cf)
932885
})

0 commit comments

Comments
 (0)