-
Notifications
You must be signed in to change notification settings - Fork 2
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
Not able to add raw data #7
Comments
Hi, can you please submit your code with which you are trying to create FS object? |
It's something like this :
Maybe I need to do some transformation over raw data returned by readFile, but I'd like to be able to read it again with a ̀̀̀`fsMock.readFile([...])`` later and get the same result. |
I see.. This should definitely work and I probably just forgot to add it, because here https://github.com/sakren/node-fs-mock/blob/develop/src/fs.coffee#L106 it is tested if it is string and here https://github.com/sakren/node-fs-mock/blob/develop/src/fs.coffee#L139-L144 it is tested if it is string or instance of Buffer class. So if you want to implement this and create pull request, I'll be really glad. Temporary workaround should be this, but it also transform data from Buffer into string:
or without specified encoding:
|
Thanks for this workaround. it works great. I'll try to submit a pull request to implement this |
It might be a desired behavior or just me doing thing in a strange way, but I'd like to use fs-mock with some binary data (a tiny
.tar
archive).The idea behind this is being allowed to test some function that performs operations on this archive without actually creating files on system.
I tried to make a readFile() of the archive then calling
new FS()
with data as a value for some file.This got me a "Unknown Type" error.
Looking at the source, I understand well how it happens. However, I don't know if it's supposed to be a desired behaviour or if it's just that raw output isn't yet implemented and it may be useful if I tried to submit a pull request on this feature
The text was updated successfully, but these errors were encountered: