diff options
author | Nicholas Ferrier <Nicholas.Ferrier@bwinparty.com> | 2014-04-21 22:07:36 +0100 |
---|---|---|
committer | Nicholas Ferrier <Nicholas.Ferrier@bwinparty.com> | 2014-04-21 22:07:36 +0100 |
commit | bb35749afbb88088c569f9bb60ffd219ac8e4d81 (patch) | |
tree | 2990c6bfcdebd228119fde64e440b8c37b152a6e | |
parent | b44b1ecbf6d66ac07215389d41377c519cf92cf2 (diff) |
add details about testing
-rw-r--r-- | README.creole | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/README.creole b/README.creole index 39de316..4886765 100644 --- a/README.creole +++ b/README.creole @@ -119,3 +119,29 @@ results in: {{{ (("a" . 17)("b" . "hello")("xyz" . "well!")) }}} + +=== Testing === + +Hash Db's are tied to filenames so to test them you often have to +manage that persistence: + +{{{ +(unwind-protect + (let ((mydb (db-make `(db-hash :filename "/tmp/mydb"))) + (json + (with-temp-buffer + (insert-file-contents "~/work/elmarmalade/users-mongo.json") + (goto-char (point-min)) + (json-read)))) + (--each json (db-put (car it) (cdr it) mydb)) + (list (db-get 'triss mydb) + (db-get 'nicferrier mydb))) + (delete-file "/tmp/mydb.elc")) +}}} + +Note the deleting of the {{{elc}}} file. That's how the hash db is +stored. + +Alternately one could use {{{fakir-file}}} (see the fakir package) to +mock the file system. But that's harder than just creating and +throwing away the file. |