forked from DGNum/liminix
import expect= where previously it was copy-pasted
This commit is contained in:
parent
73abf952d5
commit
771585546d
3 changed files with 8 additions and 29 deletions
|
@ -1,7 +1,8 @@
|
|||
(local subject (require :acquire-wan-address))
|
||||
(local { : view } (require :fennel))
|
||||
(import-macros { : expect= } :anoia.assert)
|
||||
(local { : merge : dup } (require :anoia))
|
||||
|
||||
;; nix-shell --run "cd modules/dhcp6c && fennelrepl acquire-wan-address-test.fnl"
|
||||
|
||||
(local a1
|
||||
{
|
||||
|
@ -47,19 +48,6 @@
|
|||
}
|
||||
)
|
||||
|
||||
(macro expect [assertion]
|
||||
(let [msg (.. "expectation failed: " (view assertion))]
|
||||
`(when (not ,assertion)
|
||||
(assert false ,msg))))
|
||||
|
||||
(macro expect= [actual expected]
|
||||
`(let [ve# (view ,expected)
|
||||
va# (view ,actual)]
|
||||
(when (not (= ve# va#))
|
||||
(assert false
|
||||
(.. "\nexpected " ve# "\ngot " va#)
|
||||
))))
|
||||
|
||||
(fn first-address []
|
||||
(let [deleted
|
||||
(subject.deletions
|
||||
|
|
|
@ -1,16 +1,12 @@
|
|||
(local { : view &as fennel } (require :fennel))
|
||||
(local anoia (require :anoia))
|
||||
(import-macros { : expect= } :anoia.assert)
|
||||
|
||||
;; nix-shell --run "cd pkgs/ifwait && fennelrepl test-ifwait.fnl"
|
||||
|
||||
(var fake-system (fn [s] (print "executing " s)))
|
||||
(tset anoia :system #(fake-system $1))
|
||||
|
||||
(macro expect= [actual expected]
|
||||
`(let [ve# (view ,expected)
|
||||
va# (view ,actual)]
|
||||
(when (not (= ve# va#))
|
||||
(assert false
|
||||
(.. "\nexpected " ve# "\ngot " va#)
|
||||
))))
|
||||
|
||||
(fn event-generator [events]
|
||||
(coroutine.wrap
|
||||
|
@ -117,3 +113,5 @@
|
|||
(set upsies [])
|
||||
(ifwait.run ["-s" "addmember" "dummy0" "up"] #gen)
|
||||
(expect= upsies [:u :u :u :u]))
|
||||
|
||||
(print "OK")
|
||||
|
|
|
@ -1,16 +1,9 @@
|
|||
(local { : view} (require :fennel))
|
||||
(import-macros { : expect= } :anoia.assert)
|
||||
|
||||
(set _G.arg (doto [] (tset 0 "test")))
|
||||
(local subject (require :watch))
|
||||
|
||||
(macro expect= [actual expected]
|
||||
`(let [ve# (view ,expected)
|
||||
va# (view ,actual)]
|
||||
(when (not (= ve# va#))
|
||||
(assert false
|
||||
(.. "\nexpected " ve# "\ngot " va#)
|
||||
))))
|
||||
|
||||
(let [params
|
||||
{:matches {:devname "foo" :partname "my-usbstick"}}]
|
||||
(expect= (subject.event-matches? params {}) false)
|
||||
|
|
Loading…
Reference in a new issue