2023-01-02 21:25:36 +00:00
|
|
|
(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))
|
2023-01-03 21:18:29 +00:00
|
|
|
(assert
|
|
|
|
(accumulate [found false
|
|
|
|
r (h:find "example.com")]
|
|
|
|
(or
|
|
|
|
found
|
|
|
|
(match r
|
|
|
|
{:url "http://example.com" :timestamp t} true)))))
|
2023-01-02 21:25:36 +00:00
|
|
|
|
|
|
|
(let [h (history.open)]
|
|
|
|
(h:visit "http://example.com" (fake-time))
|
|
|
|
(h:title "http://example.com" "Page title")
|
2023-01-03 21:18:29 +00:00
|
|
|
(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"))))
|