Skip to content
8 changes: 4 additions & 4 deletions cmd/app/link_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ func Test_Apps_LinkAppHeaderSection(t *testing.T) {
},
},
}
for name, tt := range tests {
for name, tc := range tests {
t.Run(name, func(t *testing.T) {
// Create mocks
ctx := slackcontext.MockContext(t.Context())
Expand All @@ -733,14 +733,14 @@ func Test_Apps_LinkAppHeaderSection(t *testing.T) {
clients := shared.NewClientFactory(clientsMock.MockClientFactory())

// Run the test
LinkAppHeaderSection(ctx, clients, tt.shouldConfirm)
LinkAppHeaderSection(ctx, clients, tc.shouldConfirm)

// Assertions
output := clientsMock.GetCombinedOutput()
for _, expectedOutput := range tt.expectedOutputs {
for _, expectedOutput := range tc.expectedOutputs {
require.Contains(t, output, expectedOutput)
}
for _, unexpectedOutput := range tt.unexpectedOutputs {
for _, unexpectedOutput := range tc.unexpectedOutputs {
require.NotContains(t, output, unexpectedOutput)
}
})
Expand Down
8 changes: 4 additions & 4 deletions cmd/app/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,14 @@ func TestAppsListFormat(t *testing.T) {
},
}

for name, tt := range tests {
for name, tc := range tests {
t.Run(name, func(t *testing.T) {
listFlags = tt.Flags
formattedList := formatListSuccess(tt.Apps)
listFlags = tc.Flags
formattedList := formatListSuccess(tc.Apps)
for ii, value := range formattedList {
formattedList[ii] = strings.TrimRight(value, ":")
}
for _, value := range tt.Expected {
for _, value := range tc.Expected {
assert.Contains(t, strings.Join(formattedList, "\n"), value)
}
})
Expand Down
14 changes: 7 additions & 7 deletions cmd/collaborators/collaborators_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,28 +98,28 @@ func TestCollaboratorsCommand(t *testing.T) {
},
}

for name, tt := range tests {
for name, tc := range tests {
t.Run(name, func(t *testing.T) {
ctx := slackcontext.MockContext(t.Context())
appSelectMock := prompts.NewAppSelectMock()
appSelectPromptFunc = appSelectMock.AppSelectPrompt
appSelectMock.On("AppSelectPrompt", mock.Anything, mock.Anything, prompts.ShowHostedOnly, prompts.ShowInstalledAndUninstalledApps).Return(prompts.SelectedApp{App: tt.app, Auth: types.SlackAuth{}}, nil)
appSelectMock.On("AppSelectPrompt", mock.Anything, mock.Anything, prompts.ShowHostedOnly, prompts.ShowInstalledAndUninstalledApps).Return(prompts.SelectedApp{App: tc.app, Auth: types.SlackAuth{}}, nil)
clientsMock := shared.NewClientsMock()
clientsMock.AddDefaultMocks()
clientsMock.API.On("ListCollaborators", mock.Anything, mock.Anything, mock.Anything).
Return(tt.collaborators, nil)
Return(tc.collaborators, nil)
clients := shared.NewClientFactory(clientsMock.MockClientFactory(), func(clients *shared.ClientFactory) {
clients.SDKConfig = hooks.NewSDKConfigMock()
})

err := NewCommand(clients).ExecuteContext(ctx)
require.NoError(t, err)
clientsMock.API.AssertCalled(t, "ListCollaborators", mock.Anything, mock.Anything, tt.app.AppID)
clientsMock.API.AssertCalled(t, "ListCollaborators", mock.Anything, mock.Anything, tc.app.AppID)
clientsMock.IO.AssertCalled(t, "PrintTrace", mock.Anything, slacktrace.CollaboratorListSuccess, mock.Anything)
clientsMock.IO.AssertCalled(t, "PrintTrace", mock.Anything, slacktrace.CollaboratorListCount, []string{
fmt.Sprintf("%d", len(tt.collaborators)),
fmt.Sprintf("%d", len(tc.collaborators)),
})
for _, collaborator := range tt.collaborators {
for _, collaborator := range tc.collaborators {
clientsMock.IO.AssertCalled(t, "PrintTrace", mock.Anything, slacktrace.CollaboratorListCollaborator, []string{
collaborator.ID,
collaborator.UserName,
Expand All @@ -128,7 +128,7 @@ func TestCollaboratorsCommand(t *testing.T) {
})
}
output := clientsMock.GetCombinedOutput()
for _, expectedOutput := range tt.expectedOutputs {
for _, expectedOutput := range tc.expectedOutputs {
require.Contains(t, output, expectedOutput)
}
})
Expand Down
14 changes: 7 additions & 7 deletions cmd/collaborators/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,28 +98,28 @@ func TestListCommand(t *testing.T) {
},
}

for name, tt := range tests {
for name, tc := range tests {
t.Run(name, func(t *testing.T) {
ctx := slackcontext.MockContext(t.Context())
appSelectMock := prompts.NewAppSelectMock()
appSelectPromptFunc = appSelectMock.AppSelectPrompt
appSelectMock.On("AppSelectPrompt", mock.Anything, mock.Anything, prompts.ShowHostedOnly, prompts.ShowInstalledAndUninstalledApps).Return(prompts.SelectedApp{App: tt.app, Auth: types.SlackAuth{}}, nil)
appSelectMock.On("AppSelectPrompt", mock.Anything, mock.Anything, prompts.ShowHostedOnly, prompts.ShowInstalledAndUninstalledApps).Return(prompts.SelectedApp{App: tc.app, Auth: types.SlackAuth{}}, nil)
clientsMock := shared.NewClientsMock()
clientsMock.AddDefaultMocks()
clientsMock.API.On("ListCollaborators", mock.Anything, mock.Anything, mock.Anything).
Return(tt.collaborators, nil)
Return(tc.collaborators, nil)
clients := shared.NewClientFactory(clientsMock.MockClientFactory(), func(clients *shared.ClientFactory) {
clients.SDKConfig = hooks.NewSDKConfigMock()
})

err := NewListCommand(clients).ExecuteContext(ctx)
require.NoError(t, err)
clientsMock.API.AssertCalled(t, "ListCollaborators", mock.Anything, mock.Anything, tt.app.AppID)
clientsMock.API.AssertCalled(t, "ListCollaborators", mock.Anything, mock.Anything, tc.app.AppID)
clientsMock.IO.AssertCalled(t, "PrintTrace", mock.Anything, slacktrace.CollaboratorListSuccess, mock.Anything)
clientsMock.IO.AssertCalled(t, "PrintTrace", mock.Anything, slacktrace.CollaboratorListCount, []string{
fmt.Sprintf("%d", len(tt.collaborators)),
fmt.Sprintf("%d", len(tc.collaborators)),
})
for _, collaborator := range tt.collaborators {
for _, collaborator := range tc.collaborators {
clientsMock.IO.AssertCalled(t, "PrintTrace", mock.Anything, slacktrace.CollaboratorListCollaborator, []string{
collaborator.ID,
collaborator.UserName,
Expand All @@ -128,7 +128,7 @@ func TestListCommand(t *testing.T) {
})
}
output := clientsMock.GetCombinedOutput()
for _, expectedOutput := range tt.expectedOutputs {
for _, expectedOutput := range tc.expectedOutputs {
require.Contains(t, output, expectedOutput)
}
})
Expand Down
28 changes: 14 additions & 14 deletions cmd/datastore/bulk_delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func TestBulkDeleteCommandPreRun(t *testing.T) {
expectedError: slackerror.New(slackerror.ErrAppNotHosted),
},
}
for name, tt := range tests {
for name, tc := range tests {
t.Run(name, func(t *testing.T) {
clientsMock := shared.NewClientsMock()
manifestMock := &app.ManifestMockObject{}
Expand All @@ -112,27 +112,27 @@ func TestBulkDeleteCommandPreRun(t *testing.T) {
mock.Anything,
mock.Anything,
).Return(
tt.mockManifestResponse,
tt.mockManifestError,
tc.mockManifestResponse,
tc.mockManifestError,
)
clientsMock.AppClient.Manifest = manifestMock
projectConfigMock := config.NewProjectConfigMock()
projectConfigMock.On(
"GetManifestSource",
mock.Anything,
).Return(
tt.mockManifestSource,
tc.mockManifestSource,
nil,
)
clientsMock.Config.ProjectConfig = projectConfigMock
clients := shared.NewClientFactory(clientsMock.MockClientFactory(), func(cf *shared.ClientFactory) {
cf.Config.ForceFlag = tt.mockFlagForce
cf.SDKConfig.WorkingDirectory = tt.mockWorkingDirectory
cf.Config.ForceFlag = tc.mockFlagForce
cf.SDKConfig.WorkingDirectory = tc.mockWorkingDirectory
})
cmd := NewBulkDeleteCommand(clients)
err := cmd.PreRunE(cmd, nil)
if tt.expectedError != nil {
assert.Equal(t, slackerror.ToSlackError(tt.expectedError).Code, slackerror.ToSlackError(err).Code)
if tc.expectedError != nil {
assert.Equal(t, slackerror.ToSlackError(tc.expectedError).Code, slackerror.ToSlackError(err).Code)
} else {
assert.NoError(t, err)
}
Expand Down Expand Up @@ -173,12 +173,12 @@ func TestBulkDeleteCommand(t *testing.T) {
},
},
}
for name, tt := range tests {
for name, tc := range tests {
t.Run(name, func(t *testing.T) {
ctx := slackcontext.MockContext(t.Context())
clientsMock := setupDatastoreMocks()
if tt.Setup != nil {
tt.Setup(clientsMock)
if tc.Setup != nil {
tc.Setup(clientsMock)
}
clients := shared.NewClientFactory(clientsMock.MockClientFactory())

Expand All @@ -198,12 +198,12 @@ func TestBulkDeleteCommand(t *testing.T) {
// Create mocked command
err := cmd.ExecuteContext(ctx)
if assert.NoError(t, err) {
bulkDeleteMock.AssertCalled(t, "BulkDelete", mock.Anything, mock.Anything, mock.Anything, tt.Query)
bulkDeleteMock.AssertCalled(t, "BulkDelete", mock.Anything, mock.Anything, mock.Anything, tc.Query)
}

// Cleanup when done
if tt.Teardown != nil {
tt.Teardown()
if tc.Teardown != nil {
tc.Teardown()
}
})
}
Expand Down
28 changes: 14 additions & 14 deletions cmd/datastore/bulk_get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func TestBulkGetCommandPreRun(t *testing.T) {
expectedError: slackerror.New(slackerror.ErrAppNotHosted),
},
}
for name, tt := range tests {
for name, tc := range tests {
t.Run(name, func(t *testing.T) {
clientsMock := shared.NewClientsMock()
manifestMock := &app.ManifestMockObject{}
Expand All @@ -112,27 +112,27 @@ func TestBulkGetCommandPreRun(t *testing.T) {
mock.Anything,
mock.Anything,
).Return(
tt.mockManifestResponse,
tt.mockManifestError,
tc.mockManifestResponse,
tc.mockManifestError,
)
clientsMock.AppClient.Manifest = manifestMock
projectConfigMock := config.NewProjectConfigMock()
projectConfigMock.On(
"GetManifestSource",
mock.Anything,
).Return(
tt.mockManifestSource,
tc.mockManifestSource,
nil,
)
clientsMock.Config.ProjectConfig = projectConfigMock
clients := shared.NewClientFactory(clientsMock.MockClientFactory(), func(cf *shared.ClientFactory) {
cf.Config.ForceFlag = tt.mockFlagForce
cf.SDKConfig.WorkingDirectory = tt.mockWorkingDirectory
cf.Config.ForceFlag = tc.mockFlagForce
cf.SDKConfig.WorkingDirectory = tc.mockWorkingDirectory
})
cmd := NewBulkGetCommand(clients)
err := cmd.PreRunE(cmd, nil)
if tt.expectedError != nil {
assert.Equal(t, slackerror.ToSlackError(tt.expectedError).Code, slackerror.ToSlackError(err).Code)
if tc.expectedError != nil {
assert.Equal(t, slackerror.ToSlackError(tc.expectedError).Code, slackerror.ToSlackError(err).Code)
} else {
assert.NoError(t, err)
}
Expand Down Expand Up @@ -173,12 +173,12 @@ func TestBulkGetCommand(t *testing.T) {
},
},
}
for name, tt := range tests {
for name, tc := range tests {
t.Run(name, func(t *testing.T) {
ctx := slackcontext.MockContext(t.Context())
clientsMock := setupDatastoreMocks()
if tt.Setup != nil {
tt.Setup(clientsMock)
if tc.Setup != nil {
tc.Setup(clientsMock)
}
clients := shared.NewClientFactory(clientsMock.MockClientFactory())

Expand All @@ -198,12 +198,12 @@ func TestBulkGetCommand(t *testing.T) {
// Perform test
err := cmd.ExecuteContext(ctx)
if assert.NoError(t, err) {
bulkGetMock.AssertCalled(t, "BulkGet", mock.Anything, mock.Anything, mock.Anything, tt.Query)
bulkGetMock.AssertCalled(t, "BulkGet", mock.Anything, mock.Anything, mock.Anything, tc.Query)
}

// Cleanup when done
if tt.Teardown != nil {
tt.Teardown()
if tc.Teardown != nil {
tc.Teardown()
}
})
}
Expand Down
28 changes: 14 additions & 14 deletions cmd/datastore/bulk_put_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func TestBulkPutCommandPreRun(t *testing.T) {
expectedError: slackerror.New(slackerror.ErrAppNotHosted),
},
}
for name, tt := range tests {
for name, tc := range tests {
t.Run(name, func(t *testing.T) {
clientsMock := shared.NewClientsMock()
manifestMock := &app.ManifestMockObject{}
Expand All @@ -117,27 +117,27 @@ func TestBulkPutCommandPreRun(t *testing.T) {
mock.Anything,
mock.Anything,
).Return(
tt.mockManifestResponse,
tt.mockManifestError,
tc.mockManifestResponse,
tc.mockManifestError,
)
clientsMock.AppClient.Manifest = manifestMock
projectConfigMock := config.NewProjectConfigMock()
projectConfigMock.On(
"GetManifestSource",
mock.Anything,
).Return(
tt.mockManifestSource,
tc.mockManifestSource,
nil,
)
clientsMock.Config.ProjectConfig = projectConfigMock
clients := shared.NewClientFactory(clientsMock.MockClientFactory(), func(cf *shared.ClientFactory) {
cf.Config.ForceFlag = tt.mockFlagForce
cf.SDKConfig.WorkingDirectory = tt.mockWorkingDirectory
cf.Config.ForceFlag = tc.mockFlagForce
cf.SDKConfig.WorkingDirectory = tc.mockWorkingDirectory
})
cmd := NewBulkPutCommand(clients)
err := cmd.PreRunE(cmd, nil)
if tt.expectedError != nil {
assert.Equal(t, slackerror.ToSlackError(tt.expectedError).Code, slackerror.ToSlackError(err).Code)
if tc.expectedError != nil {
assert.Equal(t, slackerror.ToSlackError(tc.expectedError).Code, slackerror.ToSlackError(err).Code)
} else {
assert.NoError(t, err)
}
Expand Down Expand Up @@ -190,12 +190,12 @@ func TestBulkPutCommand(t *testing.T) {
},
},
}
for name, tt := range tests {
for name, tc := range tests {
t.Run(name, func(t *testing.T) {
ctx := slackcontext.MockContext(t.Context())
clientsMock := setupDatastoreMocks()
if tt.Setup != nil {
tt.Setup(clientsMock)
if tc.Setup != nil {
tc.Setup(clientsMock)
}
clients := shared.NewClientFactory(clientsMock.MockClientFactory())

Expand All @@ -215,12 +215,12 @@ func TestBulkPutCommand(t *testing.T) {
// Perform test
err := cmd.ExecuteContext(ctx)
if assert.NoError(t, err) {
bulkPutMock.AssertCalled(t, "BulkPut", mock.Anything, mock.Anything, mock.Anything, tt.Query)
bulkPutMock.AssertCalled(t, "BulkPut", mock.Anything, mock.Anything, mock.Anything, tc.Query)
}

// Cleanup when done
if tt.Teardown != nil {
tt.Teardown()
if tc.Teardown != nil {
tc.Teardown()
}
})
}
Expand Down
Loading
Loading