Merge pull request #37 from dubo-dubon-duponey/moar

Export tests
This commit is contained in:
Andrea Luzzardi 2021-01-15 09:56:19 -08:00 committed by GitHub
commit 9a9e3b629f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 282 additions and 0 deletions

View File

@ -0,0 +1,29 @@
package testing
test: {
bool
#dagger: {
compute: [
{
do: "fetch-container"
ref: "alpine"
},
{
do: "exec"
args: ["sh", "-c", """
printf "true" > /tmp/out
"""
]
dir: "/"
},
{
do: "export"
// Source path in the container
source: "/tmp/out"
format: "bool"
},
]
}
}

View File

@ -0,0 +1,29 @@
package testing
teststring: {
string
#dagger: {
compute: [
{
do: "fetch-container"
ref: "alpine"
},
{
do: "exec"
args: ["sh", "-c", """
echo something > /tmp/out
"""
]
// XXX Blocked by https://github.com/blocklayerhq/dagger/issues/19
dir: "/"
},
{
do: "export"
// Source path in the container
source: "/tmp/out"
format: "lalalalal"
},
]
}
}

View File

@ -0,0 +1,20 @@
package testing
teststring: {
string
#dagger: {
compute: [
{
do: "fetch-container"
ref: "alpine"
},
{
do: "export"
// Source path in the container
source: "/tmp/lalala"
format: "string"
},
]
}
}

View File

@ -0,0 +1,30 @@
package testing
test: {
string
=~ "^NAAAA.+"
#dagger: {
compute: [
{
do: "fetch-container"
ref: "alpine"
},
{
do: "exec"
args: ["sh", "-c", """
printf something > /tmp/out
"""
]
// XXX Blocked by https://github.com/blocklayerhq/dagger/issues/19
dir: "/"
},
{
do: "export"
// Source path in the container
source: "/tmp/out"
format: "string"
},
]
}
}

View File

@ -0,0 +1,27 @@
package testing
test: {
#dagger: {
compute: [
{
do: "fetch-container"
ref: "alpine"
},
{
do: "exec"
args: ["sh", "-c", """
echo '{"something": "something"}' > /tmp/out
"""
]
dir: "/"
},
{
do: "export"
// Source path in the container
source: "/tmp/out"
format: "json"
},
]
}
}

View File

@ -0,0 +1,29 @@
package testing
test: {
number
#dagger: {
compute: [
{
do: "fetch-container"
ref: "alpine"
},
{
do: "exec"
args: ["sh", "-c", """
echo -123.5 > /tmp/out
"""
]
// XXX Blocked by https://github.com/blocklayerhq/dagger/issues/19
dir: "/"
},
{
do: "export"
// Source path in the container
source: "/tmp/out"
format: "number"
},
]
}
}

View File

@ -0,0 +1,29 @@
package testing
test: {
string
#dagger: {
compute: [
{
do: "fetch-container"
ref: "alpine"
},
{
do: "exec"
args: ["sh", "-c", """
printf something > /tmp/out
"""
]
// XXX Blocked by https://github.com/blocklayerhq/dagger/issues/19
dir: "/"
},
{
do: "export"
// Source path in the container
source: "/tmp/out"
format: "string"
},
]
}
}

View File

@ -0,0 +1,30 @@
package testing
test: {
string
=~ "^some.+"
#dagger: {
compute: [
{
do: "fetch-container"
ref: "alpine"
},
{
do: "exec"
args: ["sh", "-c", """
printf something > /tmp/out
"""
]
// XXX Blocked by https://github.com/blocklayerhq/dagger/issues/19
dir: "/"
},
{
do: "export"
// Source path in the container
source: "/tmp/out"
format: "string"
},
]
}
}

View File

@ -0,0 +1,29 @@
package testing
test: {
#dagger: {
compute: [
{
do: "fetch-container"
ref: "alpine"
},
{
do: "exec"
args: ["sh", "-c", """
echo "--- # Shopping list
[milk, pumpkin pie, eggs, juice]" > /tmp/out
"""
]
// XXX Blocked by https://github.com/blocklayerhq/dagger/issues/19
dir: "/"
},
{
do: "export"
// Source path in the container
source: "/tmp/out"
format: "yaml"
},
]
}
}

View File

@ -91,6 +91,35 @@ test::exec(){
# "$dagger" compute "$d"/exec/dir/exist # "$dagger" compute "$d"/exec/dir/exist
} }
test::export(){
# XXX https://github.com/blocklayerhq/dagger/issues/36
#test::one "Export: number" --exit=0 --stdout='{"test": -123.5}' \
# "$dagger" compute "$d"/export/number
#test::one "Export: yaml" --exit=0 --stdout='XXXXXX' \
# "$dagger" compute "$d"/export/yaml
# XXX https://github.com/blocklayerhq/dagger/issues/35
#test::one "Export: bool" --exit=0 --stdout='{"test": false}' \
# "$dagger" compute "$d"/export/bool
test::one "Export: json" --exit=0 --stdout='{"test":{"something":"something"}}' \
"$dagger" compute "$d"/export/json
test::one "Export: string" --exit=0 --stdout='{"test":"something"}' \
"$dagger" compute "$d"/export/string
test::one "Export: string with additional constraint success" --exit=0 --stdout='{"test":"something"}' \
"$dagger" compute "$d"/export/withvalidation
test::one "Export: does not pass additional validation" --exit=1 --stdout= \
"$dagger" compute "$d"/export/invalid/validation
test::one "Export: invalid format" --exit=1 --stdout= \
"$dagger" compute "$d"/export/invalid/format
test::one "Export: invalid path" --exit=1 --stdout= \
"$dagger" compute "$d"/export/invalid/path
}
test::all(){ test::all(){
local dagger="$1" local dagger="$1"
@ -98,6 +127,7 @@ test::all(){
test::fetchcontainer "$dagger" test::fetchcontainer "$dagger"
test::fetchgit "$dagger" test::fetchgit "$dagger"
test::exec "$dagger" test::exec "$dagger"
test::export "$dagger"
# TODO: exec mounts # TODO: exec mounts
# TODO: copy # TODO: copy