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 ( import (
"dagger.io/alpine" "dagger.io/alpine"

View File

@ -7,9 +7,10 @@ setup() {
@test "op.#Load" { @test "op.#Load" {
run "$DAGGER" compute "$TESTDIR"/ops/load/valid/component run "$DAGGER" compute "$TESTDIR"/ops/load/valid/component
assert_success 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 run "$DAGGER" compute "$TESTDIR"/ops/load/invalid/cache
assert_failure assert_failure
@ -17,30 +18,35 @@ setup() {
@test "op.#Mount" { @test "op.#Mount" {
# tmpfs # tmpfs
"$DAGGER" compute "$TESTDIR"/ops/mounts/valid/tmpfs run "$DAGGER" compute "$TESTDIR"/ops/mounts/valid/tmpfs
assert_line '{"TestMountTmpfs":"ok"}'
assert_success
# cache # 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 # component
run "$DAGGER" compute "$TESTDIR"/ops/mounts/valid/component run "$DAGGER" compute "$TESTDIR"/ops/mounts/valid/component
assert_success assert_success
assert_line '{"test":"hello world"}' assert_line '{"test":"hello world"}'
# FIXME https://github.com/blocklayerhq/dagger/issues/46 # Invalid mount path
# "$DAGGER" compute "$TESTDIR"/ops/mounts/valid/script run "$DAGGER" compute "$TESTDIR"/ops/mounts/valid/script
assert_failure
} }
@test "op.#Copy" { @test "op.#Copy" {
run "$DAGGER" compute "$TESTDIR"/ops/copy/valid/component run "$DAGGER" compute "$TESTDIR"/ops/copy/valid/component
assert_success 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
# run "$DAGGER" compute "$TESTDIR"/ops/copy/invalid/cache assert_failure
# assert_failure
} }
@test "op.#Local" { @test "op.#Local" {
@ -78,7 +84,8 @@ setup() {
@test "op.#PushContainer" { @test "op.#PushContainer" {
skip_unless_secrets_available "$TESTDIR"/ops/push-container/inputs.yaml 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" { @test "op.#FetchGit" {
@ -151,26 +158,26 @@ setup() {
# assert_failure # --exit=123 # assert_failure # --exit=123
# script with non-optional prop, not referenced, should be executed # 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
# run "$DAGGER" compute "$TESTDIR"/ops/exec/undefined/with_pkg_mandatory assert_success
# assert_failure
} }
@test "op.#Export" { @test "op.#Export" {
run "$DAGGER" compute "$TESTDIR"/ops/export/json run "$DAGGER" compute "$TESTDIR"/ops/export/json
assert_success 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 run "$DAGGER" compute "$TESTDIR"/ops/export/string
assert_success assert_success
assert_line '{"test":"something"}' assert_line '{"TestExportString":"something"}'
run "$DAGGER" compute "$TESTDIR"/ops/export/withvalidation run "$DAGGER" compute "$TESTDIR"/ops/export/withvalidation
assert_success assert_success
assert_line '{"test":"something"}' assert_line '{"TestExportStringValidation":"something"}'
run "$DAGGER" compute "$TESTDIR"/ops/export/concurrency run "$DAGGER" compute "$TESTDIR"/ops/export/concurrency
assert_success 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 # does not pass additional validation
run "$DAGGER" compute "$TESTDIR"/ops/export/invalid/validation run "$DAGGER" compute "$TESTDIR"/ops/export/invalid/validation
@ -184,31 +191,36 @@ setup() {
run "$DAGGER" compute "$TESTDIR"/ops/export/invalid/path run "$DAGGER" compute "$TESTDIR"/ops/export/invalid/path
assert_failure assert_failure
run "$DAGGER" compute "$TESTDIR"/ops/export/float run "$DAGGER" compute "$TESTDIR"/ops/export/float
assert_success assert_success
assert_line '{"test":-123.5}' assert_line '{"TestExportFloat":-123.5}'
run "$DAGGER" compute "$TESTDIR"/ops/export/yaml run "$DAGGER" compute "$TESTDIR"/ops/export/yaml
assert_success 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 run "$DAGGER" compute "$TESTDIR"/ops/export/bool
assert_success 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
# run "$DAGGER" compute "$TESTDIR"/ops/export/number assert_success
# assert_success assert_line '{"TestExportNumber":-123.5}'
# assert_line '{"test":-123.5}'
} }
@test "op.#Subdir" { @test "op.#Subdir" {
run "$DAGGER" compute "$TESTDIR"/ops/subdir/simple run "$DAGGER" compute "$TESTDIR"/ops/subdir/valid/simple
assert_success 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 assert_failure
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2,7 +2,7 @@ package testing
import "dagger.io/dagger/op" import "dagger.io/dagger/op"
testScalar: { TestExportScalar: {
bool bool
#up: [ #up: [
@ -23,35 +23,34 @@ testScalar: {
] ]
} }
// FIXME: lists are currently broken TestExportList: {
// testList: { [...string]
// [...string]
// #up: [ #up: [
// { {
// do: "fetch-container" do: "fetch-container"
// ref: "alpine" ref: "alpine"
// }, },
// { {
// do: "exec" do: "exec"
// args: ["sh", "-c", """ args: ["sh", "-c", """
// echo "--- # Shopping list echo "--- # Shopping list
// [milk, pumpkin pie, eggs, juice]" > /tmp/out [milk, pumpkin pie, eggs, juice]" > /tmp/out
// """, """,
// ] ]
// // XXX Blocked by https://github.com/blocklayerhq/dagger/issues/19 // XXX Blocked by https://github.com/blocklayerhq/dagger/issues/19
// dir: "/" dir: "/"
// }, },
// { {
// do: "export" do: "export"
// // Source path in the container // Source path in the container
// source: "/tmp/out" source: "/tmp/out"
// format: "yaml" format: "yaml"
// }, },
// ] ]
// } }
testMap: #up: [ TestExportMap: #up: [
{ {
do: "fetch-container" do: "fetch-container"
ref: "alpine" ref: "alpine"

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,8 +1,8 @@
package main package testing
import "dagger.io/dagger/op" import "dagger.io/dagger/op"
hello: { TestInvalidExecSubdir: {
string string
#up: [ #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" import "dagger.io/dagger/op"
hello: { TestSimpleSubdir: {
string string
#up: [ #up: [