dunlin/test/history.fnl

39 lines
1020 B
Fennel

(local { : view } (require :fennel))
(local history (require :history))
(local fake-time
(let []
(var previous 1672682104)
(fn []
(doto previous
(+ 1)))))
(let [h (history.open)]
(h:visit "http://example.com" (fake-time))
(assert
(accumulate [found false
r (h:find "example.com")]
(or
found
(match r
{:url "http://example.com" :timestamp t} true)))))
(let [h (history.open)]
(h:visit "http://example.com" (fake-time))
(h:title "http://example.com" "Page title")
(assert
(accumulate [found false
r (h:find "example.com")]
(or
found
(match r
{:url "http://example.com" :title "Page title" :timestamp t} true)))))
(let [h (history.open "/tmp/foo.db")]
(h:visit "http://example.com" (fake-time))
(h:visit "http://notsample.com" (+ 1 (fake-time)))
(each [r (h:find "example.com")]
(match r
{:url "http://notsample.com" } (assert false "unexpected row"))))