-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
[MM-57034]: Check for s3 object is File or Directory #26837
base: master
Are you sure you want to change the base?
Conversation
[pull] master from mattermost:master
[pull] master from mattermost:master
[pull] master from mattermost:master
[pull] master from mattermost:master
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.
Please add a test. Look at s3store_test.go. Thanks!
You can add an entirely new test. Thanks! |
This PR has been automatically labelled "stale" because it hasn't had recent activity. |
count++ | ||
} | ||
// Check if only one item was returned and it matches the path prefix | ||
if count == 1 && len(paths) > 0 && strings.TrimRight(path, "/") == strings.TrimRight(paths[0], "/") { |
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.
No need to do strings.TrimRight
for paths[0]
because it's already done inside the for loop.
_, err = fileBackend.WriteFile(bytes.NewReader(b), path1) | ||
require.NoError(t, err, "Failed to write file1 to S3") | ||
|
||
_, err = fileBackend.listDirectory("", false) |
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.
Use the exported method ListDirectory
.
require.NoError(t, err, "Failed to write file1 to S3") | ||
|
||
_, err = fileBackend.listDirectory("", false) | ||
require.Error(t, err, "readdir 19700101/: file does not exist []") |
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.
Check for the actual error type apart from just asserting for the error.
var pErr *fs.PathError
assert.True(t, errors.As(err, &pErr), "error is not of type fs.PathError")
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.
sure
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.
LGTM!
/update-branch |
/e2e-test |
E2E test triggered successfully for PR #26837. The corresponding commit's status check will be available shortly. |
E2E test run is starting for commit
|
This PR has been automatically labelled "stale" because it hasn't had recent activity. |
Summary
Fixes: #26742
Ticket Link
JIRA :- MM-57034
Screenshots
Release Note