Merge pull request #75 from dubo-dubon-duponey/tests
Work on integration tests
This commit is contained in:
commit
2009561ba5
16
examples/tests/compute/invalid/overload/new_def/main.cue
Normal file
16
examples/tests/compute/invalid/overload/new_def/main.cue
Normal file
@ -0,0 +1,16 @@
|
||||
package testing
|
||||
|
||||
bar: #dagger: {
|
||||
|
||||
#new_def: "lala"
|
||||
|
||||
compute: [{
|
||||
do: "fetch-container"
|
||||
ref: "busybox"
|
||||
},
|
||||
{
|
||||
do: "exec"
|
||||
args: ["true"]
|
||||
dir: "/"
|
||||
}]
|
||||
}
|
16
examples/tests/compute/invalid/overload/new_prop/main.cue
Normal file
16
examples/tests/compute/invalid/overload/new_prop/main.cue
Normal file
@ -0,0 +1,16 @@
|
||||
package testing
|
||||
|
||||
bar: #dagger: {
|
||||
|
||||
new_prop: "lala"
|
||||
|
||||
compute: [{
|
||||
do: "fetch-container"
|
||||
ref: "busybox"
|
||||
},
|
||||
{
|
||||
do: "exec"
|
||||
args: ["true"]
|
||||
dir: "/"
|
||||
}]
|
||||
}
|
17
examples/tests/compute/success/overload/flat/main.cue
Normal file
17
examples/tests/compute/success/overload/flat/main.cue
Normal file
@ -0,0 +1,17 @@
|
||||
package testing
|
||||
|
||||
new_prop: "lala"
|
||||
#new_def: "lala"
|
||||
|
||||
new_prop_too: string
|
||||
#new_def_too: string
|
||||
|
||||
#dagger: compute: [{
|
||||
do: "fetch-container"
|
||||
ref: "busybox"
|
||||
},
|
||||
{
|
||||
do: "exec"
|
||||
args: ["true"]
|
||||
dir: "/"
|
||||
}]
|
19
examples/tests/compute/success/overload/wrapped/main.cue
Normal file
19
examples/tests/compute/success/overload/wrapped/main.cue
Normal file
@ -0,0 +1,19 @@
|
||||
package testing
|
||||
|
||||
foo: {
|
||||
new_prop: "lala"
|
||||
#new_def: "lala"
|
||||
|
||||
new_prop_too: string
|
||||
#new_def_too: string
|
||||
|
||||
#dagger: compute: [{
|
||||
do: "fetch-container"
|
||||
ref: "busybox"
|
||||
},
|
||||
{
|
||||
do: "exec"
|
||||
args: ["true"]
|
||||
dir: "/"
|
||||
}]
|
||||
}
|
@ -3,7 +3,7 @@ package testing
|
||||
#dagger: compute: [
|
||||
{
|
||||
do: "fetch-container"
|
||||
ref: "alpine"
|
||||
ref: "busybox"
|
||||
},
|
||||
{
|
||||
do: "exec"
|
@ -1,17 +0,0 @@
|
||||
package testing
|
||||
|
||||
hello: "world"
|
||||
|
||||
bar: string
|
||||
|
||||
#dagger: compute: [
|
||||
{
|
||||
do: "fetch-container"
|
||||
ref: "alpine"
|
||||
},
|
||||
{
|
||||
do: "exec"
|
||||
dir: "/"
|
||||
args: ["sh", "-c", "echo \(bar)"]
|
||||
},
|
||||
]
|
14
examples/tests/exec/exit_code/main.cue
Normal file
14
examples/tests/exec/exit_code/main.cue
Normal file
@ -0,0 +1,14 @@
|
||||
package testing
|
||||
|
||||
#dagger: compute: [
|
||||
{
|
||||
do: "fetch-container"
|
||||
ref: "alpine"
|
||||
},
|
||||
{
|
||||
do: "exec"
|
||||
args: ["sh", "-c", "exit 123"]
|
||||
// XXX Blocked by https://github.com/blocklayerhq/dagger/issues/19
|
||||
dir: "/"
|
||||
},
|
||||
]
|
@ -0,0 +1,20 @@
|
||||
package testing
|
||||
|
||||
hello: "world"
|
||||
bar: string
|
||||
|
||||
#dagger: compute: [
|
||||
{
|
||||
do: "fetch-container"
|
||||
ref: "alpine"
|
||||
},
|
||||
{
|
||||
do: "exec"
|
||||
dir: "/"
|
||||
args: ["sh", "-c", """
|
||||
echo \(hello)
|
||||
echo "This test SHOULD fail, because this script SHOULD execute, since bar is not referenced"
|
||||
exit 1
|
||||
"""]
|
||||
},
|
||||
]
|
@ -0,0 +1,20 @@
|
||||
package testing
|
||||
|
||||
hello: "world"
|
||||
bar: string
|
||||
|
||||
#dagger: compute: [
|
||||
{
|
||||
do: "fetch-container"
|
||||
ref: "alpine"
|
||||
},
|
||||
{
|
||||
do: "exec"
|
||||
dir: "/"
|
||||
args: ["sh", "-c", """
|
||||
echo \(bar)
|
||||
echo "This test SHOULD succeed, because this is never going to be executed, as \(bar) is not concrete"
|
||||
exit 1
|
||||
"""]
|
||||
},
|
||||
]
|
@ -0,0 +1 @@
|
||||
module: "dagger.cloud/testing"
|
@ -0,0 +1,19 @@
|
||||
package def
|
||||
|
||||
#dang: string
|
||||
|
||||
#dagger: {
|
||||
compute: [
|
||||
{
|
||||
do: "fetch-container"
|
||||
ref: "alpine"
|
||||
},
|
||||
{
|
||||
do: "exec"
|
||||
dir: "/"
|
||||
args: ["sh", "-c", """
|
||||
echo success
|
||||
"""]
|
||||
},
|
||||
]
|
||||
}
|
14
examples/tests/exec/undefined/with_pkg_def/main.cue
Normal file
14
examples/tests/exec/undefined/with_pkg_def/main.cue
Normal file
@ -0,0 +1,14 @@
|
||||
package testing
|
||||
|
||||
import (
|
||||
"dagger.cloud/def"
|
||||
)
|
||||
|
||||
#dagger: {
|
||||
compute: [
|
||||
{
|
||||
do: "load",
|
||||
from: def
|
||||
},
|
||||
]
|
||||
}
|
@ -0,0 +1 @@
|
||||
module: "dagger.cloud/testing"
|
@ -0,0 +1,20 @@
|
||||
package nonoptional
|
||||
|
||||
dang: string
|
||||
|
||||
#dagger: {
|
||||
compute: [
|
||||
{
|
||||
do: "fetch-container"
|
||||
ref: "alpine"
|
||||
},
|
||||
{
|
||||
do: "exec"
|
||||
dir: "/"
|
||||
args: ["sh", "-c", """
|
||||
echo "This test SHOULD fail, because this SHOULD be executed"
|
||||
exit 1
|
||||
"""]
|
||||
},
|
||||
]
|
||||
}
|
14
examples/tests/exec/undefined/with_pkg_mandatory/main.cue
Normal file
14
examples/tests/exec/undefined/with_pkg_mandatory/main.cue
Normal file
@ -0,0 +1,14 @@
|
||||
package testing
|
||||
|
||||
import (
|
||||
"dagger.cloud/nonoptional"
|
||||
)
|
||||
|
||||
#dagger: {
|
||||
compute: [
|
||||
{
|
||||
do: "load",
|
||||
from: nonoptional
|
||||
},
|
||||
]
|
||||
}
|
@ -0,0 +1 @@
|
||||
module: "dagger.cloud/testing"
|
@ -0,0 +1,19 @@
|
||||
package optional
|
||||
|
||||
dang?: string
|
||||
|
||||
#dagger: {
|
||||
compute: [
|
||||
{
|
||||
do: "fetch-container"
|
||||
ref: "alpine"
|
||||
},
|
||||
{
|
||||
do: "exec"
|
||||
dir: "/"
|
||||
args: ["sh", "-c", """
|
||||
echo success
|
||||
"""]
|
||||
},
|
||||
]
|
||||
}
|
14
examples/tests/exec/undefined/with_pkg_optional/main.cue
Normal file
14
examples/tests/exec/undefined/with_pkg_optional/main.cue
Normal file
@ -0,0 +1,14 @@
|
||||
package testing
|
||||
|
||||
import (
|
||||
"dagger.cloud/optional"
|
||||
)
|
||||
|
||||
#dagger: {
|
||||
compute: [
|
||||
{
|
||||
do: "load",
|
||||
from: optional
|
||||
},
|
||||
]
|
||||
}
|
@ -16,7 +16,7 @@ readonly DAGGER_BINARY_ARGS
|
||||
test::compute(){
|
||||
local dagger="$1"
|
||||
|
||||
# Compute
|
||||
# Compute: invalid syntax
|
||||
test::one "Compute: invalid string should fail" --exit=1 --stdout= \
|
||||
"$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/compute/invalid/string
|
||||
test::one "Compute: invalid bool should fail" --exit=1 --stdout= \
|
||||
@ -25,12 +25,20 @@ test::compute(){
|
||||
"$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/compute/invalid/int
|
||||
test::one "Compute: invalid struct should fail" --exit=1 --stdout= \
|
||||
"$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/compute/invalid/struct
|
||||
test::one "Compute: overloading #ComponentScript with new prop should fail" --exit=1 \
|
||||
"$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/compute/invalid/overload/new_prop
|
||||
test::one "Compute: overloading #ComponentScript with new def should fail" --exit=1 \
|
||||
"$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/compute/invalid/overload/new_def
|
||||
|
||||
# Compute: success
|
||||
test::one "Compute: noop should succeed" --exit=0 --stdout='{"empty":{},"realempty":{}}' \
|
||||
"$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/compute/noop
|
||||
"$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/compute/success/noop
|
||||
test::one "Compute: simple should succeed" --exit=0 --stdout="{}" \
|
||||
"$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/compute/simple
|
||||
test::one "Compute: script with undefined values should not fail" --exit=0 --stdout='{"hello":"world"}' \
|
||||
"$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/compute/undefined_prop
|
||||
"$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/compute/success/simple
|
||||
test::one "Compute: overloading #Component should work" --exit=0 \
|
||||
"$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/compute/success/overload/flat
|
||||
test::one "Compute: overloading #Component should work" --exit=0 \
|
||||
"$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/compute/success/overload/wrapped
|
||||
}
|
||||
|
||||
test::fetchcontainer(){
|
||||
@ -92,6 +100,21 @@ test::exec(){
|
||||
"$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/exec/dir/doesnotexist
|
||||
test::one "Exec: valid dir" --exit=0 --stdout={} \
|
||||
"$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/exec/dir/exist
|
||||
|
||||
disable test::one "Exec: exit code propagation (FIXME https://github.com/blocklayerhq/dagger/issues/74)" --exit=123 \
|
||||
"$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/exec/exit_code
|
||||
|
||||
test::one "Exec: script with referenced non-concrete property should not be executed, and should succeed overall" --exit=0 --stdout='{"hello":"world"}' \
|
||||
"$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/exec/undefined/non_concrete_referenced
|
||||
# NOTE: the exec is meant to fail - and we test that as a way to confirm it has been executed
|
||||
test::one "Exec: script with unreferenced undefined properties should be executed" --exit=1 \
|
||||
"$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/exec/undefined/non_concrete_not_referenced
|
||||
test::one "Exec: package with optional def, not referenced, should be executed" --exit=0 \
|
||||
"$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/exec/undefined/with_pkg_def
|
||||
test::one "Exec: script with optional prop, not referenced, should be executed" --exit=0 \
|
||||
"$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/exec/undefined/with_pkg_optional
|
||||
disable test::one "Exec: script with non-optional prop, not referenced, should be executed (FIXME https://github.com/blocklayerhq/dagger/issues/70)" --exit=1 \
|
||||
"$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/exec/undefined/with_pkg_mandatory
|
||||
}
|
||||
|
||||
test::export(){
|
||||
|
Reference in New Issue
Block a user