WIP add failing test that service starts
This commit is contained in:
parent
570d29c368
commit
5d5dff6729
2 changed files with 34 additions and 2 deletions
|
@ -2,12 +2,13 @@
|
||||||
|
|
||||||
; (local { : view} (require :fennel))
|
; (local { : view} (require :fennel))
|
||||||
|
|
||||||
(local { : assoc } (require :anoia))
|
(local { : assoc : system } (require :anoia))
|
||||||
|
|
||||||
(fn parse-args [args]
|
(fn parse-args [args]
|
||||||
(match args
|
(match args
|
||||||
["-v" & rest] (assoc (parse-args rest) :verbose true)
|
["-v" & rest] (assoc (parse-args rest) :verbose true)
|
||||||
["-t" timeout & rest] (assoc (parse-args rest) :timeout (tonumber timeout))
|
["-t" timeout & rest] (assoc (parse-args rest) :timeout (tonumber timeout))
|
||||||
|
["-s" service & rest] (assoc (parse-args rest) :service service)
|
||||||
[linkname "up"] {:link linkname :expecting "up"}
|
[linkname "up"] {:link linkname :expecting "up"}
|
||||||
[linkname "running"] {:link linkname :expecting "running"}
|
[linkname "running"] {:link linkname :expecting "running"}
|
||||||
[linkname "present"] {:link linkname :expecting "present"}
|
[linkname "present"] {:link linkname :expecting "present"}
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
(local fennel (require :fennel))
|
(local { : view &as fennel } (require :fennel))
|
||||||
|
(local anoia (require :anoia))
|
||||||
|
|
||||||
|
(var fake-system (fn [s] (print "executing " s)))
|
||||||
|
(tset anoia :system #(fake-system $1))
|
||||||
|
|
||||||
(fn event-generator [events]
|
(fn event-generator [events]
|
||||||
(coroutine.wrap
|
(coroutine.wrap
|
||||||
|
@ -19,3 +23,30 @@
|
||||||
(match (pcall gen)
|
(match (pcall gen)
|
||||||
(true _) true
|
(true _) true
|
||||||
(false msg) (error "didn't detect dummy0 up event")))
|
(false msg) (error "didn't detect dummy0 up event")))
|
||||||
|
|
||||||
|
(var succeeded? false)
|
||||||
|
(set fake-system
|
||||||
|
(fn [s]
|
||||||
|
(print "exec" s)
|
||||||
|
(if (s:match "addmember") (set succeeded? true))))
|
||||||
|
|
||||||
|
(let [events
|
||||||
|
[{:event "newlink"
|
||||||
|
:hwaddr "b6:7d:5c:38:89:1d"
|
||||||
|
:index 21
|
||||||
|
:mtu 1500
|
||||||
|
:name "dummy0"
|
||||||
|
:running "no"
|
||||||
|
:stamp 857161382
|
||||||
|
:up "no"}
|
||||||
|
{:event "newlink"
|
||||||
|
:hwaddr "52:f0:46:da:0c:0c"
|
||||||
|
:index 22
|
||||||
|
:mtu 1500
|
||||||
|
:name "dummy0"
|
||||||
|
:running "no"
|
||||||
|
:stamp 857161383
|
||||||
|
:up "yes"}]
|
||||||
|
gen (event-generator events)]
|
||||||
|
(ifwait.run ["-v" "-s" "addmember" "dummy0" "up"] #gen)
|
||||||
|
(assert succeeded?))
|
||||||
|
|
Loading…
Reference in a new issue