-
Notifications
You must be signed in to change notification settings - Fork 39
feat: conclude set-icon experiment #623
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
srtaalej
wants to merge
2
commits into
main
Choose a base branch
from
release-set-icon
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,15 +16,13 @@ package apps | |
|
|
||
| import ( | ||
| "bytes" | ||
| "context" | ||
| "fmt" | ||
| "testing" | ||
|
|
||
| "github.com/slackapi/slack-cli/internal/api" | ||
| "github.com/slackapi/slack-cli/internal/app" | ||
| "github.com/slackapi/slack-cli/internal/cache" | ||
| "github.com/slackapi/slack-cli/internal/config" | ||
| "github.com/slackapi/slack-cli/internal/experiment" | ||
| "github.com/slackapi/slack-cli/internal/shared" | ||
| "github.com/slackapi/slack-cli/internal/shared/types" | ||
| "github.com/slackapi/slack-cli/internal/slackcontext" | ||
|
|
@@ -1811,45 +1809,11 @@ func Test_resolveIconPath(t *testing.T) { | |
|
|
||
| func Test_updateIcon(t *testing.T) { | ||
| tests := map[string]struct { | ||
| isHosted bool | ||
| experimentOn bool | ||
| expectIconSet bool | ||
| expectIcon bool | ||
| expectSkip bool | ||
| mockError error | ||
| expectedError bool | ||
| }{ | ||
| "experiment on + hosted app uses IconSet": { | ||
| isHosted: true, | ||
| experimentOn: true, | ||
| expectIconSet: true, | ||
| }, | ||
| "experiment on + non-hosted app uses IconSet": { | ||
| isHosted: false, | ||
| experimentOn: true, | ||
| expectIconSet: true, | ||
| }, | ||
| "experiment off + hosted app uses Icon": { | ||
| isHosted: true, | ||
| experimentOn: false, | ||
| expectIcon: true, | ||
| }, | ||
| "experiment off + non-hosted app skips upload": { | ||
| isHosted: false, | ||
| experimentOn: false, | ||
| expectSkip: true, | ||
| }, | ||
| "succeeds with IconSet": {}, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧪 note: This test doesn't seem so useful without mock data included. Another comment suggested deleting the function it's testing and IMHO this is supported here. Otherwise I'd suggest including:
|
||
| "returns error from IconSet": { | ||
| isHosted: false, | ||
| experimentOn: true, | ||
| expectIconSet: true, | ||
| mockError: fmt.Errorf("api error"), | ||
| expectedError: true, | ||
| }, | ||
| "returns error from Icon": { | ||
| isHosted: true, | ||
| experimentOn: false, | ||
| expectIcon: true, | ||
| mockError: fmt.Errorf("api error"), | ||
| expectedError: true, | ||
| }, | ||
|
|
@@ -1860,35 +1824,19 @@ func Test_updateIcon(t *testing.T) { | |
| clientsMock := shared.NewClientsMock() | ||
| clientsMock.AddDefaultMocks() | ||
|
|
||
| if tc.experimentOn { | ||
| clientsMock.Config.ExperimentsFlag = []string{string(experiment.SetIcon)} | ||
| clientsMock.Config.LoadExperiments(ctx, func(_ context.Context, _ string, _ ...interface{}) {}) | ||
| } | ||
|
|
||
| clientsMock.API.On("IconSet", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything). | ||
| Return(api.IconResult{}, tc.mockError) | ||
| clientsMock.API.On("Icon", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything). | ||
| Return(api.IconResult{}, tc.mockError) | ||
|
|
||
| clients := shared.NewClientFactory(clientsMock.MockClientFactory()) | ||
| err := updateIcon(ctx, clients, "icon.png", "A001", "xoxe-token", tc.isHosted) | ||
| err := updateIcon(ctx, clients, "icon.png", "A001", "xoxe-token") | ||
|
|
||
| if tc.expectedError { | ||
| require.Error(t, err) | ||
| } else { | ||
| require.NoError(t, err) | ||
| } | ||
|
|
||
| if tc.expectIconSet { | ||
| clientsMock.API.AssertCalled(t, "IconSet", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything) | ||
| clientsMock.API.AssertNotCalled(t, "Icon") | ||
| } else if tc.expectIcon { | ||
| clientsMock.API.AssertCalled(t, "Icon", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything) | ||
| clientsMock.API.AssertNotCalled(t, "IconSet") | ||
| } else if tc.expectSkip { | ||
| clientsMock.API.AssertNotCalled(t, "Icon") | ||
| clientsMock.API.AssertNotCalled(t, "IconSet") | ||
| } | ||
| clientsMock.API.AssertCalled(t, "IconSet", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything) | ||
| }) | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🪓 suggestion: This function is used once in
Installand I think we can now inline the API call to matchInstallLocalpatterns? I'd like to avoid separate patterns now that the experiment has concluded.