clean up & bugfix

Signed-off-by: Solomon Hykes <sh.github.6811@hykes.org>
This commit is contained in:
Solomon Hykes
2021-01-07 16:54:52 -08:00
parent 3162ca0991
commit c5842f894a
14 changed files with 166 additions and 129 deletions

View File

@@ -5,9 +5,37 @@ import (
"testing"
)
func TestLocalScript(t *testing.T) {
cc := &Compiler{}
src := `[{do: "local", dir: "foo"}]`
v, err := cc.Compile("", src)
if err != nil {
t.Fatal(err)
}
s, err := v.Script()
if err != nil {
t.Fatal(err)
}
n := 0
err = s.Walk(func(op *Op) error {
n += 1
return nil
})
if err != nil {
t.Fatal(err)
}
if n != 1 {
t.Fatal(n)
}
}
func TestWalkBootScript(t *testing.T) {
cc := &Compiler{}
script, err := cc.CompileScript("boot.cue", defaultBootScript)
cfg, err := cc.Compile("clientconfig.cue", defaultBootScript)
if err != nil {
t.Fatal(err)
}
script, err := cfg.Get("bootscript").Script()
if err != nil {
t.Fatal(err)
}