Skip to content
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 tests that break expectation for Options.FS #162

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mafredri
Copy link

This commit adds tests to reproduce #153.

I believe this is what is being referred to in #153. It would be nice to be able to use the provided FS for both read and write operations.

Understandably this is not the case since io/fs doesn't support write operations but it would be very nice if this was a supported use-case.

At the very least, it may be good to update docs to reflect this limitation.

This commit adds tests to reproduce otiai10#153.
_, err = os.Stat(filepath.Join(subdir, dest))
Expect(t, err).ToBe(nil)
})
When(t, "fs copy relative when fs is root", func(t *testing.T) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could roll the ball either way whether or not this is an error or a feature. Here Copy is not respecting the working directory when using FS, if it was the test would pass.

OTOH, when providing the FS you might not want this behavior.

Expect(t, err).ToBe(nil)

_, err = os.Stat(filepath.Join(subdir, dest))
Expect(t, err).ToBe(nil)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

err := Copy("test/data/case18/assets", dest, Options{
FS: os.DirFS("/"),
})
Expect(t, err).ToBe(nil)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@otiai10
Copy link
Owner

otiai10 commented Aug 21, 2024

Thanks a lot! Let me take time to check it out 🙇
You saved my life. It's so appreciated

@otiai10 otiai10 self-assigned this Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants