history.fnl (1020B)
1 (local { : view } (require :fennel)) 2 3 (local history (require :history)) 4 5 (local fake-time 6 (let [] 7 (var previous 1672682104) 8 (fn [] 9 (doto previous 10 (+ 1))))) 11 12 (let [h (history.open)] 13 (h:visit "http://example.com" (fake-time)) 14 (assert 15 (accumulate [found false 16 r (h:find "example.com")] 17 (or 18 found 19 (match r 20 {:url "http://example.com" :timestamp t} true))))) 21 22 (let [h (history.open)] 23 (h:visit "http://example.com" (fake-time)) 24 (h:title "http://example.com" "Page title") 25 (assert 26 (accumulate [found false 27 r (h:find "example.com")] 28 (or 29 found 30 (match r 31 {:url "http://example.com" :title "Page title" :timestamp t} true))))) 32 33 (let [h (history.open "/tmp/foo.db")] 34 (h:visit "http://example.com" (fake-time)) 35 (h:visit "http://notsample.com" (+ 1 (fake-time))) 36 (each [r (h:find "example.com")] 37 (match r 38 {:url "http://notsample.com" } (assert false "unexpected row"))))