aboutsummaryrefslogtreecommitdiff
path: root/lib/memfs/node_test.go
AgeCommit message (Collapse)Author
2024-12-28lib/memfs: refactoring Watch to use "watchfs/v2"Shulhan
2024-03-02all: move the repository to "git.sr.ht/~shulhan/pakakeh.go"Shulhan
There are several reasons that why we move from github.com. First, related to the name of package. We accidentally name the package with "share" a common word in English that does not reflect the content of repository. By moving to other repository, we can rename it to better and unique name, in this "pakakeh.go". Pakakeh is Minang word for tools, and ".go" suffix indicate that the repository related to Go programming language. Second, supporting open source. The new repository is hosted under sourcehut.org, the founder is known to support open source, and all their services are licensed under AGPL, unlike GitHub that are closed sources. Third, regarding GitHub CoPilot. The GitHub Terms of Service [1], allow any public content that are hosted there granted them to parse the content. On one side, GitHub helps and flourish the open source, but on another side have an issues regarding scraping the copyleft license [2]. [1]: https://docs.github.com/en/site-policy/github-terms/github-terms-of-service#4-license-grant-to-us [2]: https://githubcopilotinvestigation.com
2021-12-19lib/memfs: realign struct Node, Options, PathNode, and on unit testsShulhan
The realign save storage spaces on struct, * Node: from 240 to 224 bytes (-16 bytes) * Options: from 112 to 104 bytes (-8 bytes) * PathNode: from 16 to 8 bytes (-8 bytes)
2021-12-19lib/memfs: remove field ContentEncoding from EmbedOptions and NodeShulhan
The original idea for option ContentEncoding in EmbedOptions and Node is to save spaces, compressing the content on disk on embedding and doing transport, when the MemFS instance is used to serve the (embedded) contents of file system. This option turns out break the HTTP content negotiation [1] of accept-encoding header, if the HTTP server does not handle it properly, which default Go HTTP server does not. In order to prevent this issue in the future, for anyone who use the memfs for serving static HTTP contents, we remove the options and store the embedded content as is and let the HTTP server handle how the compression by itself. [1] https://developer.mozilla.org/en-US/docs/Web/HTTP/Content_negotiation
2021-10-09lib/memfs: prefix all error when the method or function namesShulhan
One of the hardest when multiple packages is used is to detect where there error happened. For example, if a program return an error io.EOF, it's hard to detect the exact method or function that caused its, especially when processing multiple files with network connection.
2021-10-09lib/memfs: use temporary directory for testing Node.Save()Shulhan
Previously we use the "testdata" for output of Node.Save() test. This is caused the modified time on "testdata" get changes every time we run the test and cause the embed_test failed. This changes use temporary directory and revert part of Node Save() unit test from commit 792ba17ac1f.
2021-10-09lib/memfs: refactoring Node field V into ContentShulhan
The reason why the field named V is because it's short. It's come from my C/C++ experience that got carried away when writing this package. Now, after having more time writing Go, I prefer clarity over cleverity(?).
2021-08-23lib/memfs: fix the test due to unremoved node_save file on testdataShulhan
2021-08-22lib/memfs: add method Save and EncodeShulhan
The Save method will write the new content to file system and update the content of Node using Encode().
2021-03-14all: refactoring the test.Assert and test.AssertBench signatureShulhan
Previously, the test.Assert and test.AssertBench functions has the boolean parameter to print the stack trace of test in case its not equal. Since this parameter is not mandatory and its usually always set to "true", we remove them from function signature to simplify the call to Assert and AssertBench.
2021-01-08memfs: remove field WithContentShulhan
The field WithContent is not necessary if we set MaxFileSize to negative value.
2021-01-08memfs: refactoring, allow multiple instances of memfs in single packageShulhan
Previously, the generated Go code from memfs can be used only once on the package that use it. For example, if we have two instances of memfs.MemFS and both of them call GoGenerate(), when we load them back again only the last one will be active and set the global variable memfs.GeneratedPathNode. This changes refactoring on how we use memfs by storing the generated path node into variable that is defined by user and pass them to New Options. This changes affect package http and io.
2020-06-10all: update email addressShulhan
2020-05-07memfs: simplify the API, add directory parameter to NewShulhan
This changes add parameter directory to be mounted in New(), so user did not need to call Mount manually This cause the Mount method and its sibling, Unmount and IsMounted become unneeded, so we remove them.
2019-12-10memfs: simplify and fix the implementation and test of ReaddirShulhan
2019-12-10memfs: fix the test on Readdir to make it predictableShulhan
2019-12-09memfs: implement http.File on NodeShulhan
2019-12-09memfs: implement os.FileInfo on NodeShulhan
2019-12-09memfs: implement io.Closer, io.Reader, and io.Seeker on NodeShulhan