Merge pull request #1189 from aluzzardi/cleanup-tests

tests: move compute tests away
This commit is contained in:
Andrea Luzzardi 2021-12-08 16:11:55 -05:00 committed by GitHub
commit d2af60d484
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
61 changed files with 21 additions and 109 deletions

View File

@ -1,26 +0,0 @@
package testing
import "alpha.dagger.io/dagger/op"
X1=in: string | *"default input"
test: {
string
#up: [
op.#FetchContainer & {
ref: "alpine"
},
op.#Exec & {
args: ["sh", "-c", """
echo -n "received: \(X1)" > /out
"""]
// XXX Blocked by https://github.com/blocklayerhq/dagger/issues/19
dir: "/"
},
op.#Export & {
source: "/out"
format: "string"
},
]
}

View File

@ -1,26 +0,0 @@
package testing
import "alpha.dagger.io/dagger/op"
X1=in: string
test: {
string
#up: [
op.#FetchContainer & {
ref: "alpine"
},
op.#Exec & {
args: ["sh", "-c", """
echo -n "received: \(X1)" > /out
"""]
// XXX Blocked by https://github.com/blocklayerhq/dagger/issues/19
dir: "/"
},
op.#Export & {
source: "/out"
format: "string"
},
]
}

View File

@ -1 +0,0 @@
module: ""

View File

@ -1,2 +0,0 @@
# dagger universe
alpha.dagger.io

View File

@ -1 +0,0 @@
module: ""

View File

@ -1,2 +0,0 @@
# dagger universe
alpha.dagger.io

View File

@ -46,98 +46,68 @@ setup() {
}
@test "compute: simple" {
run "$DAGGER" compute "$TESTDIR"/compute/invalid/string
@test "core: simple" {
run "$DAGGER" compute "$TESTDIR"/core/compute/invalid/string
assert_failure
run "$DAGGER" compute "$TESTDIR"/compute/invalid/bool
run "$DAGGER" compute "$TESTDIR"/core/compute/invalid/bool
assert_failure
run "$DAGGER" compute "$TESTDIR"/compute/invalid/int
run "$DAGGER" compute "$TESTDIR"/core/compute/invalid/int
assert_failure
run "$DAGGER" compute "$TESTDIR"/compute/invalid/struct
run "$DAGGER" compute "$TESTDIR"/core/compute/invalid/struct
assert_failure
run "$DAGGER" compute "$TESTDIR"/compute/success/noop
run "$DAGGER" compute "$TESTDIR"/core/compute/success/noop
assert_success
assert_line '{"empty":{}}'
run "$DAGGER" compute "$TESTDIR"/compute/success/simple
run "$DAGGER" compute "$TESTDIR"/core/compute/success/simple
assert_success
assert_line '{}'
run "$DAGGER" compute "$TESTDIR"/compute/success/overload/flat
run "$DAGGER" compute "$TESTDIR"/core/compute/success/overload/flat
assert_success
run "$DAGGER" compute "$TESTDIR"/compute/success/overload/wrapped
run "$DAGGER" compute "$TESTDIR"/core/compute/success/overload/wrapped
assert_success
run "$DAGGER" compute "$TESTDIR"/compute/success/exec-nocache
run "$DAGGER" compute "$TESTDIR"/core/compute/success/exec-nocache
assert_success
}
@test "compute: dependencies" {
run "$DAGGER" compute "$TESTDIR"/compute/dependencies/simple
@test "core: dependencies" {
run "$DAGGER" compute "$TESTDIR"/core/dependencies/simple
assert_success
assert_line '{"A":{"result":"from A"},"B":{"result":"dependency from A"}}'
run "$DAGGER" compute "$TESTDIR"/compute/dependencies/interpolation
run "$DAGGER" compute "$TESTDIR"/core/dependencies/interpolation
assert_success
assert_line '{"A":{"result":"from A"},"B":{"result":"dependency from A"}}'
run "$DAGGER" compute "$TESTDIR"/compute/dependencies/unmarshal
run "$DAGGER" compute "$TESTDIR"/core/dependencies/unmarshal
assert_success
assert_line '{"A":"{\"hello\": \"world\"}\n","B":{"result":"unmarshalled.hello=world"},"unmarshalled":{"hello":"world"}}'
}
@test "compute: inputs" {
run "$DAGGER" compute "$TESTDIR"/compute/input/simple
assert_success
assert_line '{}'
run "$DAGGER" compute --input-string 'in=foobar' "$TESTDIR"/compute/input/simple
assert_success
assert_line '{"in":"foobar","test":"received: foobar"}'
run "$DAGGER" compute "$TESTDIR"/compute/input/default
assert_success
assert_line '{"in":"default input","test":"received: default input"}'
run "$DAGGER" compute --input-string 'in=foobar' "$TESTDIR"/compute/input/default
assert_success
assert_line '{"in":"foobar","test":"received: foobar"}'
run "$DAGGER" compute --input-string=foobar "$TESTDIR"/compute/input/default
assert_failure
assert_output --partial 'failed to parse input: input-string'
run "$DAGGER" compute --input-dir=foobar "$TESTDIR"/compute/input/default
assert_failure
assert_output --partial 'failed to parse input: input-dir'
run "$DAGGER" compute --input-git=foobar "$TESTDIR"/compute/input/default
assert_failure
assert_output --partial 'failed to parse input: input-git'
}
@test "compute: secrets" {
@test "core: secrets" {
# secrets used as environment variables must fail
run "$DAGGER" compute "$TESTDIR"/compute/secrets/invalid/env
run "$DAGGER" compute "$TESTDIR"/core/secrets/invalid/env
assert_failure
assert_line --partial "conflicting values"
# strings passed as secrets must fail
run "$DAGGER" compute "$TESTDIR"/compute/secrets/invalid/string
run "$DAGGER" compute "$TESTDIR"/core/secrets/invalid/string
assert_failure
# Setting a text input for a secret value should fail
run "$DAGGER" compute --input-string 'mySecret=SecretValue' "$TESTDIR"/compute/secrets/simple
run "$DAGGER" compute --input-string 'mySecret=SecretValue' "$TESTDIR"/core/secrets/simple
assert_failure
# Now test with an actual secret and make sure it works
"$DAGGER" init
dagger_new_with_plan secrets "$TESTDIR"/compute/secrets/simple
dagger_new_with_plan secrets "$TESTDIR"/core/secrets/simple
"$DAGGER" input secret mySecret SecretValue
run "$DAGGER" up
assert_success
@ -176,6 +146,6 @@ setup() {
"$DAGGER" -e test-arm up --no-cache
}
@test "compute: exclude" {
"$DAGGER" up --project "$TESTDIR"/compute/exclude
@test "core: exclude" {
"$DAGGER" up --project "$TESTDIR"/core/exclude
}