@@ -19,8 +19,6 @@ import (
1919 "errors"
2020 "testing"
2121
22- "github.com/slackapi/slack-cli/internal/app"
23- "github.com/slackapi/slack-cli/internal/config"
2422 "github.com/slackapi/slack-cli/internal/iostreams"
2523 "github.com/slackapi/slack-cli/internal/shared"
2624 "github.com/slackapi/slack-cli/internal/shared/types"
@@ -34,88 +32,22 @@ import (
3432
3533func TestExternalAuthAddClientSecretCommandPreRun (t * testing.T ) {
3634 tests := map [string ]struct {
37- mockFlagForce bool
38- mockManifestResponse types.SlackYaml
39- mockManifestError error
40- mockManifestSource config.ManifestSource
4135 mockWorkingDirectory string
4236 expectedError error
4337 }{
44- "continues if the application is hosted on slack" : {
45- mockManifestResponse : types.SlackYaml {
46- AppManifest : types.AppManifest {
47- Settings : & types.AppSettings {
48- FunctionRuntime : types .SlackHosted ,
49- },
50- },
51- },
52- mockManifestError : nil ,
38+ "continues if the command is run in a valid project directory" : {
5339 mockWorkingDirectory : "/slack/path/to/project" ,
5440 expectedError : nil ,
5541 },
56- "errors if the application is not hosted on slack" : {
57- mockManifestResponse : types.SlackYaml {
58- AppManifest : types.AppManifest {
59- Settings : & types.AppSettings {
60- FunctionRuntime : types .Remote ,
61- },
62- },
63- },
64- mockManifestError : nil ,
65- mockManifestSource : config .ManifestSourceLocal ,
66- mockWorkingDirectory : "/slack/path/to/project" ,
67- expectedError : slackerror .New (slackerror .ErrAppNotHosted ),
68- },
69- "continues if the force flag is used in a project" : {
70- mockFlagForce : true ,
71- mockWorkingDirectory : "/slack/path/to/project" ,
72- expectedError : nil ,
73- },
74- "errors if the project manifest cannot be retrieved" : {
75- mockManifestResponse : types.SlackYaml {},
76- mockManifestError : slackerror .New (slackerror .ErrSDKHookInvocationFailed ),
77- mockManifestSource : config .ManifestSourceLocal ,
78- mockWorkingDirectory : "/slack/path/to/project" ,
79- expectedError : slackerror .New (slackerror .ErrSDKHookInvocationFailed ),
80- },
8142 "errors if the command is not run in a project" : {
82- mockManifestResponse : types.SlackYaml {},
83- mockManifestError : slackerror .New (slackerror .ErrSDKHookNotFound ),
84- mockManifestSource : config .ManifestSourceLocal ,
8543 mockWorkingDirectory : "" ,
8644 expectedError : slackerror .New (slackerror .ErrInvalidAppDirectory ),
8745 },
88- "errors if the manifest source is set to remote" : {
89- mockManifestSource : config .ManifestSourceRemote ,
90- mockWorkingDirectory : "/slack/path/to/project" ,
91- expectedError : slackerror .New (slackerror .ErrAppNotHosted ),
92- },
9346 }
9447 for name , tc := range tests {
9548 t .Run (name , func (t * testing.T ) {
9649 clientsMock := shared .NewClientsMock ()
97- manifestMock := & app.ManifestMockObject {}
98- manifestMock .On (
99- "GetManifestLocal" ,
100- mock .Anything ,
101- mock .Anything ,
102- mock .Anything ,
103- ).Return (
104- tc .mockManifestResponse ,
105- tc .mockManifestError ,
106- )
107- clientsMock .AppClient .Manifest = manifestMock
108- projectConfigMock := config .NewProjectConfigMock ()
109- projectConfigMock .On (
110- "GetManifestSource" ,
111- mock .Anything ,
112- ).Return (
113- tc .mockManifestSource ,
114- nil ,
115- )
116- clientsMock .Config .ProjectConfig = projectConfigMock
11750 clients := shared .NewClientFactory (clientsMock .MockClientFactory (), func (cf * shared.ClientFactory ) {
118- cf .Config .ForceFlag = tc .mockFlagForce
11951 cf .SDKConfig .WorkingDirectory = tc .mockWorkingDirectory
12052 })
12153 cmd := NewAddClientSecretCommand (clients )
0 commit comments