-
Notifications
You must be signed in to change notification settings - Fork 26
refactor(tests): convert the higher risk slice-to-map table tests #324
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
11aa4f7
refactor(tests): use tests/tc naming in table tests using the slice p…
mwbrooks 048e6cb
Merge branch 'main' into mwbrooks-table-test-consistent
mwbrooks 3933f61
test: update map pattern table tests to use common naming pattern
mwbrooks 3b361c3
test: update slice pattern table tests to map pattern (simple use-cases)
mwbrooks 58dcc8b
Merge branch 'main' into mwbrooks-table-test-consistent-p3-slice-to-m…
mwbrooks 7a210a8
refactor(tests): cleanup formatting
mwbrooks b26fd64
refactor(tests): convert the low-risk slice-to-map table tests
mwbrooks 3a3c826
test: change TODO to a regular comment
mwbrooks 54566d5
refactor(tests): convert the medium-risk slice-to-map table tests
mwbrooks 3a7df9f
refactor(tests): convert the medium-high risk slice-to-map table tests
mwbrooks 0557fc1
refactor(tests): update test name casing
mwbrooks a13ed27
refactor(tests): convert the higher risk slice-to-map table tests
mwbrooks 9a782c9
refactor(tests): fix test not wrapped in t.Run
mwbrooks 856b3c6
Merge branch 'main' into mwbrooks-table-test-consistent-p7-high-risk
mwbrooks 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -692,46 +692,48 @@ func TestAppClient_CleanupAppsJSONFiles(t *testing.T) { | |
| }, | ||
| } | ||
|
|
||
| for _, tc := range tests { | ||
| ac, _, _, pathToAppsJSON, pathToDevAppsJSON, teardown := setup(t) | ||
| defer teardown(t) | ||
| ctx := slackcontext.MockContext(t.Context()) | ||
|
|
||
| err := afero.WriteFile(ac.fs, pathToAppsJSON, tc.appsJSON, 0600) | ||
| require.NoError(t, err) | ||
| err = afero.WriteFile(ac.fs, pathToDevAppsJSON, tc.devAppsJSON, 0600) | ||
| require.NoError(t, err) | ||
|
|
||
| _, err = ac.fs.Stat(pathToAppsJSON) | ||
| require.NoError(t, err, "failed to access the apps.json file") | ||
| deployedApps, _, err := ac.GetDeployedAll(ctx) | ||
| require.NoError(t, err) | ||
|
|
||
| _, err = ac.fs.Stat(pathToDevAppsJSON) | ||
| require.NoError(t, err, "failed to access the apps.dev.json file") | ||
| localApps, err := ac.GetLocalAll(ctx) | ||
| require.NoError(t, err) | ||
|
|
||
| ac.CleanUp() | ||
|
|
||
| dotSlackFolder := filepath.Dir(pathToAppsJSON) | ||
| _, err = ac.fs.Stat(dotSlackFolder) | ||
| require.NoError(t, err, "failed to access the .slack directory") | ||
|
|
||
| appsJSON, err := afero.ReadFile(ac.fs, pathToAppsJSON) | ||
| if len(deployedApps) == 0 { | ||
| require.ErrorIs(t, err, os.ErrNotExist, "apps.json was not deleted") | ||
| } else { | ||
| for name, tc := range tests { | ||
|
Member
Author
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 ---/+++ looks scary, but it's just fixing this test by wrapping each iteration in a |
||
| t.Run(name, func(t *testing.T) { | ||
| ac, _, _, pathToAppsJSON, pathToDevAppsJSON, teardown := setup(t) | ||
| defer teardown(t) | ||
| ctx := slackcontext.MockContext(t.Context()) | ||
|
|
||
| err := afero.WriteFile(ac.fs, pathToAppsJSON, tc.appsJSON, 0600) | ||
| require.NoError(t, err) | ||
| err = afero.WriteFile(ac.fs, pathToDevAppsJSON, tc.devAppsJSON, 0600) | ||
| require.NoError(t, err) | ||
|
|
||
| _, err = ac.fs.Stat(pathToAppsJSON) | ||
| require.NoError(t, err, "failed to access the apps.json file") | ||
| assert.Equal(t, appsJSONExample, appsJSON) | ||
| } | ||
| deployedApps, _, err := ac.GetDeployedAll(ctx) | ||
| require.NoError(t, err) | ||
|
|
||
| devAppsJSON, err := afero.ReadFile(ac.fs, pathToDevAppsJSON) | ||
| if len(localApps) == 0 { | ||
| require.ErrorIs(t, err, os.ErrNotExist, "apps.dev.json was not deleted") | ||
| } else { | ||
| _, err = ac.fs.Stat(pathToDevAppsJSON) | ||
| require.NoError(t, err, "failed to access the apps.dev.json file") | ||
| assert.Equal(t, devAppsJSONExample, devAppsJSON) | ||
| } | ||
| localApps, err := ac.GetLocalAll(ctx) | ||
| require.NoError(t, err) | ||
|
|
||
| ac.CleanUp() | ||
|
|
||
| dotSlackFolder := filepath.Dir(pathToAppsJSON) | ||
| _, err = ac.fs.Stat(dotSlackFolder) | ||
| require.NoError(t, err, "failed to access the .slack directory") | ||
|
|
||
| appsJSON, err := afero.ReadFile(ac.fs, pathToAppsJSON) | ||
| if len(deployedApps) == 0 { | ||
| require.ErrorIs(t, err, os.ErrNotExist, "apps.json was not deleted") | ||
| } else { | ||
| require.NoError(t, err, "failed to access the apps.json file") | ||
| assert.Equal(t, appsJSONExample, appsJSON) | ||
| } | ||
|
|
||
| devAppsJSON, err := afero.ReadFile(ac.fs, pathToDevAppsJSON) | ||
| if len(localApps) == 0 { | ||
| require.ErrorIs(t, err, os.ErrNotExist, "apps.dev.json was not deleted") | ||
| } else { | ||
| require.NoError(t, err, "failed to access the apps.dev.json file") | ||
| assert.Equal(t, devAppsJSONExample, devAppsJSON) | ||
| } | ||
| }) | ||
| } | ||
| } | ||
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
Oops, something went wrong.
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.
note: This naming convention is a little strange, but I decided to keep it 1-to-1 with current implementation.