Unit tests to reproduce issue #19 and narrow down root cause.
Signed-off-by: Solomon Hykes <sh.github.6811@hykes.org>
This commit is contained in:
@@ -6,6 +6,44 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
// Test that default values in spec are applied
|
||||
func TestScriptDefaults(t *testing.T) {
|
||||
cc := &Compiler{}
|
||||
v, err := cc.Compile("", `
|
||||
{
|
||||
do: "exec"
|
||||
args: ["sh", "-c", """
|
||||
echo hello > /tmp/out
|
||||
"""]
|
||||
// dir: "/"
|
||||
}
|
||||
`)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
op, err := v.Op()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := op.Validate(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
dir, err := op.Get("dir").String()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if dir != "/" {
|
||||
t.Fatal(dir)
|
||||
}
|
||||
t.Skip("FIXME: issue #19")
|
||||
// Walk triggers issue #19 UNLESS optional fields removed from spec.cue
|
||||
if err := op.Walk(context.TODO(), func(op *Op) error {
|
||||
return nil
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateEmptyValue(t *testing.T) {
|
||||
cc := &Compiler{}
|
||||
v, err := cc.Compile("", "#dagger: compute: _")
|
||||
|
Reference in New Issue
Block a user