Merge pull request #371 from TomChv/test-naming-convention

This commit is contained in:
Andrea Luzzardi 2021-04-24 14:04:36 -07:00 committed by GitHub
commit c8dbbaa1c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 222 additions and 142 deletions

View File

@ -1,4 +1,4 @@
package test
package testing
import (
"dagger.io/alpine"

View File

@ -7,9 +7,10 @@ setup() {
@test "op.#Load" {
run "$DAGGER" compute "$TESTDIR"/ops/load/valid/component
assert_success
assert_line '{"component":{},"test1":"lol","test2":"lol"}'
assert_line '{"TestComponent":{},"TestComponentLoad":"lol","TestNestedLoad":"lol"}'
"$DAGGER" compute "$TESTDIR"/ops/load/valid/script
run "$DAGGER" compute "$TESTDIR"/ops/load/valid/script
assert_success
run "$DAGGER" compute "$TESTDIR"/ops/load/invalid/cache
assert_failure
@ -17,30 +18,35 @@ setup() {
@test "op.#Mount" {
# tmpfs
"$DAGGER" compute "$TESTDIR"/ops/mounts/valid/tmpfs
run "$DAGGER" compute "$TESTDIR"/ops/mounts/valid/tmpfs
assert_line '{"TestMountTmpfs":"ok"}'
assert_success
# cache
"$DAGGER" compute "$TESTDIR"/ops/mounts/valid/cache
run "$DAGGER" compute "$TESTDIR"/ops/mounts/valid/cache
assert_line '{"TestMountCache":"NOT SURE WHAT TO TEST YET"}'
assert_success
# component
run "$DAGGER" compute "$TESTDIR"/ops/mounts/valid/component
assert_success
assert_line '{"test":"hello world"}'
# FIXME https://github.com/blocklayerhq/dagger/issues/46
# "$DAGGER" compute "$TESTDIR"/ops/mounts/valid/script
# Invalid mount path
run "$DAGGER" compute "$TESTDIR"/ops/mounts/valid/script
assert_failure
}
@test "op.#Copy" {
run "$DAGGER" compute "$TESTDIR"/ops/copy/valid/component
assert_success
assert_line '{"component":{},"test1":"lol","test2":"lol"}'
assert_line '{"TestComponent":{},"TestComponentCopy":"lol","TestNestedCopy":"lol"}'
"$DAGGER" compute "$TESTDIR"/ops/copy/valid/script
run "$DAGGER" compute "$TESTDIR"/ops/copy/valid/script
assert_success
# FIXME https://github.com/blocklayerhq/dagger/issues/44
# run "$DAGGER" compute "$TESTDIR"/ops/copy/invalid/cache
# assert_failure
run "$DAGGER" compute "$TESTDIR"/ops/copy/invalid/cache
assert_failure
}
@test "op.#Local" {
@ -78,7 +84,8 @@ setup() {
@test "op.#PushContainer" {
skip_unless_secrets_available "$TESTDIR"/ops/push-container/inputs.yaml
"$DAGGER" compute --input-yaml "$TESTDIR"/ops/push-container/inputs.yaml "$TESTDIR"/ops/push-container
run "$DAGGER" compute --input-yaml "$TESTDIR"/ops/push-container/inputs.yaml "$TESTDIR"/ops/push-container
assert_success
}
@test "op.#FetchGit" {
@ -151,26 +158,26 @@ setup() {
# assert_failure # --exit=123
# script with non-optional prop, not referenced, should be executed
# FIXME https://github.com/blocklayerhq/dagger/issues/70
# run "$DAGGER" compute "$TESTDIR"/ops/exec/undefined/with_pkg_mandatory
# assert_failure
run "$DAGGER" compute "$TESTDIR"/ops/exec/undefined/with_pkg_mandatory
assert_success
}
@test "op.#Export" {
run "$DAGGER" compute "$TESTDIR"/ops/export/json
assert_success
assert_line '{"testMap":{"something":"something"},"testScalar":true}'
assert_line '{"TestExportList":["milk","pumpkin pie","eggs","juice"],"TestExportMap":{"something":"something"},"TestExportScalar":true}'
run "$DAGGER" compute "$TESTDIR"/ops/export/string
assert_success
assert_line '{"test":"something"}'
assert_line '{"TestExportString":"something"}'
run "$DAGGER" compute "$TESTDIR"/ops/export/withvalidation
assert_success
assert_line '{"test":"something"}'
assert_line '{"TestExportStringValidation":"something"}'
run "$DAGGER" compute "$TESTDIR"/ops/export/concurrency
assert_success
assert_line '{"TestExportConcurrency1":"lol1","TestExportConcurrency10":"lol10","TestExportConcurrency2":"lol2","TestExportConcurrency3":"lol3","TestExportConcurrency4":"lol4","TestExportConcurrency5":"lol5","TestExportConcurrency6":"lol6","TestExportConcurrency7":"lol7","TestExportConcurrency8":"lol8","TestExportConcurrency9":"lol9"}'
# does not pass additional validation
run "$DAGGER" compute "$TESTDIR"/ops/export/invalid/validation
@ -184,31 +191,36 @@ setup() {
run "$DAGGER" compute "$TESTDIR"/ops/export/invalid/path
assert_failure
run "$DAGGER" compute "$TESTDIR"/ops/export/float
assert_success
assert_line '{"test":-123.5}'
assert_line '{"TestExportFloat":-123.5}'
run "$DAGGER" compute "$TESTDIR"/ops/export/yaml
assert_success
assert_line '{"testMap":{"something":"something"},"testScalar":true}'
assert_line '{"TestExportList":["milk","pumpkin pie","eggs","juice"],"TestExportMap":{"something":"something"},"TestExportScalar":true}'
run "$DAGGER" compute "$TESTDIR"/ops/export/bool
assert_success
assert_line '{"test":true}'
assert_line '{"TestExportBool":true}'
# FIXME: https://github.com/blocklayerhq/dagger/issues/96
# run "$DAGGER" compute "$TESTDIR"/ops/export/number
# assert_success
# assert_line '{"test":-123.5}'
run "$DAGGER" compute "$TESTDIR"/ops/export/number
assert_success
assert_line '{"TestExportNumber":-123.5}'
}
@test "op.#Subdir" {
run "$DAGGER" compute "$TESTDIR"/ops/subdir/simple
run "$DAGGER" compute "$TESTDIR"/ops/subdir/valid/simple
assert_success
assert_line '{"hello":"world"}'
assert_line '{"TestSimpleSubdir":"world"}'
run "$DAGGER" compute "$TESTDIR"/ops/subdir/error
run "$DAGGER" compute "$TESTDIR"/ops/subdir/valid/container
assert_success
assert_line '{"TestSubdirMount":"world"}'
run "$DAGGER" compute "$TESTDIR"/ops/subdir/invalid/exec
assert_failure
run "$DAGGER" compute "$TESTDIR"/ops/subdir/invalid/path
assert_failure
}

View File

@ -2,7 +2,7 @@ package testing
import "dagger.io/dagger/op"
test1: {
TestCacheCopyLoadAlpine: {
string
#up: [
@ -25,7 +25,7 @@ test1: {
]
}
test2: {
TestCacheCopy: {
string
#up: [

View File

@ -2,7 +2,7 @@ package testing
import "dagger.io/dagger/op"
component: #up: [
TestComponent: #up: [
op.#FetchContainer & {
ref: "alpine"
},
@ -13,7 +13,7 @@ component: #up: [
},
]
test1: {
TestComponentCopy: {
string
#up: [
@ -21,7 +21,7 @@ test1: {
ref: "busybox"
},
op.#Copy & {
from: component
from: TestComponent
src: "/id"
dest: "/"
},
@ -32,7 +32,7 @@ test1: {
]
}
test2: {
TestNestedCopy: {
string
#up: [

View File

@ -2,7 +2,7 @@ package testing
import "dagger.io/dagger/op"
test: {
TestScriptCopy: {
string
#up: [

View File

@ -1,4 +1,4 @@
package test
package testing
import (
"dagger.io/dagger"

View File

@ -2,7 +2,7 @@ package testing
import "dagger.io/dagger/op"
test: {
TestExportBool: {
bool
#up: [

View File

@ -2,7 +2,7 @@ package testing
import "dagger.io/dagger/op"
test1: {
TestExportConcurrency1: {
string
#up: [
@ -11,7 +11,7 @@ test1: {
},
op.#Exec & {
args: ["sh", "-c", """
echo lol1 > /tmp/out
echo -n lol1 > /tmp/out
"""]
dir: "/"
always: true
@ -23,7 +23,7 @@ test1: {
]
}
test2: {
TestExportConcurrency2: {
string
#up: [
@ -32,7 +32,7 @@ test2: {
},
op.#Exec & {
args: ["sh", "-c", """
echo lol2 > /tmp/out
echo -n lol2 > /tmp/out
"""]
dir: "/"
always: true
@ -44,7 +44,7 @@ test2: {
]
}
test3: {
TestExportConcurrency3: {
string
#up: [
@ -53,7 +53,7 @@ test3: {
},
op.#Exec & {
args: ["sh", "-c", """
echo lol3 > /tmp/out
echo -n lol3 > /tmp/out
"""]
dir: "/"
always: true
@ -65,7 +65,7 @@ test3: {
]
}
test4: {
TestExportConcurrency4: {
string
#up: [
@ -74,7 +74,7 @@ test4: {
},
op.#Exec & {
args: ["sh", "-c", """
echo lol4 > /tmp/out
echo -n lol4 > /tmp/out
"""]
dir: "/"
always: true
@ -86,7 +86,7 @@ test4: {
]
}
test5: {
TestExportConcurrency5: {
string
#up: [
@ -95,7 +95,7 @@ test5: {
},
op.#Exec & {
args: ["sh", "-c", """
echo lol5 > /tmp/out
echo -n lol5 > /tmp/out
"""]
always: true
},
@ -106,7 +106,7 @@ test5: {
]
}
test6: {
TestExportConcurrency6: {
string
#up: [
@ -115,7 +115,7 @@ test6: {
},
op.#Exec & {
args: ["sh", "-c", """
echo lol6 > /tmp/out
echo -n lol6 > /tmp/out
"""]
always: true
},
@ -126,7 +126,7 @@ test6: {
]
}
test7: {
TestExportConcurrency7: {
string
#up: [
@ -135,7 +135,7 @@ test7: {
},
op.#Exec & {
args: ["sh", "-c", """
echo lol7 > /tmp/out
echo -n lol7 > /tmp/out
"""]
always: true
},
@ -146,7 +146,7 @@ test7: {
]
}
test8: {
TestExportConcurrency8: {
string
#up: [
@ -155,7 +155,7 @@ test8: {
},
op.#Exec & {
args: ["sh", "-c", """
echo lol8 > /tmp/out
echo -n lol8 > /tmp/out
"""]
dir: "/"
always: true
@ -167,7 +167,7 @@ test8: {
]
}
test9: {
TestExportConcurrency9: {
string
#up: [
@ -176,7 +176,7 @@ test9: {
},
op.#Exec & {
args: ["sh", "-c", """
echo lol9 > /tmp/out
echo -n lol9 > /tmp/out
"""]
dir: "/"
always: true
@ -188,7 +188,7 @@ test9: {
]
}
test10: {
TestExportConcurrency10: {
string
#up: [
@ -197,7 +197,7 @@ test10: {
},
op.#Exec & {
args: ["sh", "-c", """
echo lol10 > /tmp/out
echo -n lol10 > /tmp/out
"""]
dir: "/"
always: true

View File

@ -2,7 +2,7 @@ package testing
import "dagger.io/dagger/op"
test: {
TestExportFloat: {
float
#up: [

View File

@ -2,7 +2,7 @@ package testing
import "dagger.io/dagger/op"
teststring: {
TestExportInvalidFormat: {
string
#up: [

View File

@ -1,6 +1,6 @@
package testing
teststring: {
TestExportInvalidPath: {
string
#up: [

View File

@ -2,7 +2,7 @@ package testing
import "dagger.io/dagger/op"
test: {
TestExportInvalidValidation: {
string
=~"^NAAAA.+"
@ -12,7 +12,7 @@ test: {
},
op.#Exec & {
args: ["sh", "-c", """
printf something > /tmp/out
echo -n something > /tmp/out
""",
]
},

View File

@ -2,7 +2,7 @@ package testing
import "dagger.io/dagger/op"
testScalar: {
TestExportScalar: {
bool
#up: [
@ -23,7 +23,7 @@ testScalar: {
]
}
testMap: #up: [
TestExportMap: #up: [
op.#FetchContainer & {
ref: "alpine"
},
@ -40,28 +40,27 @@ testMap: #up: [
},
]
// FIXME: lists are currently broken
// testList: {
// [...string]
TestExportList: {
[...string]
// #up: [
// {
// do: "fetch-container"
// ref: "alpine"
// },
// {
// do: "exec"
// args: ["sh", "-c", """
// echo '["milk", "pumpkin pie", "eggs", "juice"]' > /tmp/out
// """,
// ]
// dir: "/"
// },
// {
// do: "export"
// // Source path in the container
// source: "/tmp/out"
// format: "json"
// },
// ]
// }
#up: [
{
do: "fetch-container"
ref: "alpine"
},
{
do: "exec"
args: ["sh", "-c", """
echo '["milk", "pumpkin pie", "eggs", "juice"]' > /tmp/out
""",
]
dir: "/"
},
{
do: "export"
// Source path in the container
source: "/tmp/out"
format: "json"
},
]
}

View File

@ -2,7 +2,7 @@ package testing
import "dagger.io/dagger/op"
test: {
TestExportNumber: {
number
#up: [

View File

@ -2,7 +2,7 @@ package testing
import "dagger.io/dagger/op"
test: {
TestExportString: {
string
#up: [

View File

@ -2,7 +2,7 @@ package testing
import "dagger.io/dagger/op"
test: {
TestExportStringValidation: {
string
=~"^some.+"

View File

@ -2,7 +2,7 @@ package testing
import "dagger.io/dagger/op"
testScalar: {
TestExportScalar: {
bool
#up: [
@ -23,35 +23,34 @@ testScalar: {
]
}
// FIXME: lists are currently broken
// testList: {
// [...string]
TestExportList: {
[...string]
// #up: [
// {
// 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"
// },
// ]
// }
#up: [
{
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"
},
]
}
testMap: #up: [
TestExportMap: #up: [
{
do: "fetch-container"
ref: "alpine"

View File

@ -2,31 +2,31 @@ package testing
import "dagger.io/dagger/op"
busybox1: #up: [
TestBusybox1: #up: [
op.#FetchContainer & {
ref: "busybox"
},
]
busybox2: #up: [
TestBusybox2: #up: [
op.#FetchContainer & {
ref: "busybox:latest"
},
]
busybox3: #up: [
TestBusybox3: #up: [
op.#FetchContainer & {
ref: "busybox:1.33-musl"
},
]
busybox4: #up: [
TestBusybox4: #up: [
op.#FetchContainer & {
ref: "busybox@sha256:e2af53705b841ace3ab3a44998663d4251d33ee8a9acaf71b66df4ae01c3bbe7"
},
]
busybox5: #up: [
TestBusybox5: #up: [
op.#FetchContainer & {
ref: "busybox:1.33-musl@sha256:e2af53705b841ace3ab3a44998663d4251d33ee8a9acaf71b66df4ae01c3bbe7"
},

View File

@ -2,7 +2,7 @@ package testing
import "dagger.io/dagger/op"
component: #up: [
TestComponent: #up: [
op.#FetchContainer & {
ref: "alpine"
},
@ -13,12 +13,12 @@ component: #up: [
},
]
test1: {
TestComponentLoad: {
string
#up: [
op.#Load & {
from: component
from: TestComponent
},
op.#Export & {
source: "/id"
@ -27,7 +27,7 @@ test1: {
]
}
test2: {
TestNestedLoad: {
string
#up: [

View File

@ -2,7 +2,7 @@ package testing
import "dagger.io/dagger/op"
test: {
TestMountCache: {
string
#up: [
@ -11,7 +11,7 @@ test: {
},
op.#Exec & {
args: ["sh", "-c", """
echo "NOT SURE WHAT TO TEST YET" > /out
echo -n "NOT SURE WHAT TO TEST YET" > /out
"""]
dir: "/"
mount: something: "cache"

View File

@ -2,7 +2,7 @@ package testing
import "dagger.io/dagger/op"
test: {
TestInvalidMountPath: {
string
#up: [
@ -18,7 +18,7 @@ test: {
ls -lA /lol > /out
"""]
mount: something: {
input: [{
from: [{
do: "fetch-container"
ref: "alpine"
}]

View File

@ -2,7 +2,7 @@ package testing
import "dagger.io/dagger/op"
test: {
TestMountTmpfs: {
string
#up: [
@ -15,8 +15,8 @@ test: {
},
op.#Exec & {
args: ["sh", "-c", """
echo ok > /out
echo ok > /tmpdir/out
echo -n ok > /out
echo -n ok > /tmpdir/out
"""]
mount: "/tmpdir": "tmpfs"
},

View File

@ -1,4 +1,4 @@
package main
package testing
import (
"dagger.io/dagger/op"

View File

@ -1,8 +1,8 @@
package main
package testing
import "dagger.io/dagger/op"
hello: {
TestInvalidExecSubdir: {
string
#up: [

View File

@ -0,0 +1,26 @@
package testing
import "dagger.io/dagger/op"
TestInvalidPathSubdir: {
string
#up: [
op.#FetchContainer & {
ref: "alpine"
},
op.#Exec & {
args: ["mkdir", "-p", "/tmp/foo"]
},
op.#Exec & {
args: ["sh", "-c", "echo -n world > /tmp/foo/hello"]
},
op.#Subdir & {
dir: "/directorynotfound"
},
op.#Export & {
source: "./hello"
format: "string"
},
]
}

View File

@ -0,0 +1,44 @@
package testing
import "dagger.io/dagger/op"
#TestContainer: #up: [
op.#FetchContainer & {
ref: "alpine"
},
op.#Exec & {
args: ["mkdir", "-p", "/tmp/foo"]
},
op.#Exec & {
args: ["sh", "-c", "echo -n world > /tmp/foo/hello"]
},
op.#Subdir & {
dir: "/tmp/foo"
},
]
TestSubdirMount: {
string
#up: [
op.#FetchContainer & {
ref: "alpine"
},
// Check number of file in /source (should contains only hello)
op.#Exec & {
args: ["sh", "-c", "test $(ls /source | wc -l) = 1"]
mount: "/source": from: #TestContainer
},
op.#Exec & {
args: ["sh", "-c", "cat /source/hello > /out"]
mount: "/source": from: #TestContainer
},
op.#Export & {
source: "/out"
format: "string"
},
]
}

View File

@ -1,8 +1,8 @@
package main
package testing
import "dagger.io/dagger/op"
hello: {
TestSimpleSubdir: {
string
#up: [