Skip to content
This repository was archived by the owner on Dec 14, 2023. It is now read-only.
/ ephemera Public archive

Tiny clojure library to ease creating temporary directories and files during testing

License

Notifications You must be signed in to change notification settings

curvelogic/ephemera

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ephemera

A tiny Clojure library intended to ease any testing that requires having some dummy files on disk.

It is not always feasible to mock out file system access in unit tests.

Usage

ephemera.fs provides a write-tree! function which makes it very easy to write create a temporary directory complete with file content.

Simply pass a nested map of filenames and content and write-tree! generates the whole lot returning a File instance for the root.

(use 'ephemera.fs)
;; => nil
(def root (write-tree!
             {"file-a" "This content goes in file-a"
              "subdir" {"file-b.txt" "More text\nin here\n"
                         "foo.sh" "#!/bin/bash\necho Hello World!"}}))
;; => #'user/root
root
;; => #<File /var/folders/qx/j3bsbrc56xz_63gpcg2sldzm0000gn/T/4409939888475616075>
$ ls -R /var/folders/qx/j3bsbrc56xz_63gpcg2sldzm0000gn/T/4409939888475616075
file-a	subdir

/var/folders/qx/j3bsbrc56xz_63gpcg2sldzm0000gn/T/4409939888475616075/subdir:
file-b.txt	foo.sh
$ cat /var/folders/qx/j3bsbrc56xz_63gpcg2sldzm0000gn/T/4409939888475616075/subdir/foo.sh
#!/bin/bash
echo Hello World!

Currently the file content must be a string or a nested map. If you need anything else, simply extend the ephemera.fs/FSContent protocol to the type you need.

The map is just a map.

That's it.

License

Copyright © 2015 Greg Hawkins

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

About

Tiny clojure library to ease creating temporary directories and files during testing

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published