-
Notifications
You must be signed in to change notification settings - Fork 142
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
Add and use a new IsPathAccessible API before accessing the .git dir #1006
Conversation
true
if there's no permission to access the directory "github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestIsPathExistsAndIsPathAccessible(t *testing.T) { |
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.
for isAccessible should we create a file without permissions and test that it returns false as expected?
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.
I tried adding a test that creates a file without permissions, but you have no idea how challenging it is to test this. The major challenge comes from the fact that Windows and Linux/MacOS treat files without permissions completely differently. It is hard to make all OS work inside a single test. The only option I found was to split the test into two files, so that only one of them compilers for Windows. This is due to a package that can handle Windows locking. I ended up giving up and just testing the IsPathAccessible API with non existing files. It's just not worth the complexity @sverdlov93.
This is an attempt to fix jfrog/jfrog-cli#2442.
The PR adds a new
IsPathAccessible
API, in addition to the existingIsPathExists
functions. This is because the existingIsPathExists
returnsfalse
in case of any error that occurred while accessing the directory, and not only in the case that the directory doesn't exist.The new
IsPathAccessible
returnsfalse
in case the directory exists, but the user doesn't have permissions to access it. The usage of the new API by the Artifactory Upload code flow is expected to resolve the above issue.