This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
dagger/tests/plan.bats
Helder Correia da90baa087
Add new Client API
Signed-off-by: Helder Correia <174525+helderco@users.noreply.github.com>
2022-03-07 17:13:16 -01:00

232 lines
5.8 KiB
Bash

setup() {
load 'helpers'
common_setup
}
@test "plan/hello" {
# Europa loader handles the cwd differently, therefore we need to CD into the tree at or below the parent of cue.mod
cd "$TESTDIR"
"$DAGGER" "do" -p ./plan/hello-europa test
}
@test "plan/client/filesystem/read/fs/usage" {
cd "$TESTDIR/plan/client/filesystem/read/fs"
"$DAGGER" "do" -p ./usage test valid
run "$DAGGER" "do" -p ./usage test conflictingValues
assert_failure
assert_output --partial 'conflicting values "local directory" and "local foobar"'
run "$DAGGER" "do" -p ./usage test excluded
assert_failure
assert_line --partial 'test.log: no such file or directory'
run "$DAGGER" "do" -p ./usage test notExists
assert_failure
assert_output --partial 'test.json: no such file or directory'
}
@test "plan/client/filesystem/read/fs/not_exists" {
cd "$TESTDIR/plan/client/filesystem/read/fs/not_exists"
run "$DAGGER" "do" -p . test
assert_failure
assert_output --partial 'path "/foobar" does not exist'
}
@test "plan/client/filesystem/read/fs/relative" {
cd "$TESTDIR/plan/client/filesystem/read/fs/relative"
"$DAGGER" "do" -p . test valid
run "$DAGGER" "do" -p . test notIncluded
assert_failure
assert_output --partial 'test.log: no such file or directory'
}
@test "plan/client/filesystem/read/file" {
cd "$TESTDIR/plan/client/filesystem/read/file"
"$DAGGER" "do" -p . test usage
run "$DAGGER" "do" -p . test concrete
assert_failure
assert_output --partial "unexpected concrete value"
}
@test "plan/client/filesystem/read/service" {
cd "$TESTDIR"
"$DAGGER" "do" -p ./plan/client/filesystem/read/service/valid.cue test
run "$DAGGER" "do" -p ./plan/client/filesystem/read/service/invalid.cue test
assert_failure
}
@test "plan/client/filesystem/write fs" {
cd "$TESTDIR/plan/client/filesystem/write"
rm -rf "./out_fs"
"$DAGGER" "do" -p . test fs
assert [ "$(cat ./out_fs/test)" = "foobar" ]
rm -rf "./out_fs"
}
@test "plan/client/filesystem/write files" {
cd "$TESTDIR/plan/client/filesystem/write"
mkdir -p ./out_files
rm -f ./out_files/*
# -- string --
"$DAGGER" "do" -p ./ test file
assert [ "$(cat ./out_files/test.txt)" = "foobaz" ]
run ls -l "./out_files/test.txt"
assert_output --partial "-rw-r--r--"
# -- secret --
"$DAGGER" "do" -p ./ test secret
assert [ "$(cat ./out_files/secret.txt)" = "foo-barab-oof" ]
run ls -l "./out_files/secret.txt"
assert_output --partial "-rw-------"
rm -rf ./out_files
}
@test "plan/client/filesystem/conflict" {
cd "$TESTDIR/plan/client/filesystem/conflict"
echo -n foo > test.txt
run "$DAGGER" "do" --log-level debug -p . test
assert_line --regexp "client\.filesystem\..+\.write.+dependency=client\.filesystem\..+\.read"
rm -f test.txt
}
@test "plan/client/env usage" {
cd "${TESTDIR}"
export TEST_STRING="foo"
export TEST_SECRET="bar"
"$DAGGER" "do" -p ./plan/client/env test usage
}
@test "plan/client/env not exists" {
cd "${TESTDIR}"
run "$DAGGER" "do" -p ./plan/client/env test usage
assert_failure
}
@test "plan/client/env invalid" {
cd "${TESTDIR}"
export TEST_FAIL="foobar"
run "$DAGGER" "do" -p ./plan/client/env test concrete
assert_failure
assert_output --partial "TEST_FAIL: unexpected concrete value"
}
@test "plan/client/commands" {
cd "${TESTDIR}/plan/client/commands"
"$DAGGER" "do" -p . test valid
run "$DAGGER" "do" -p . test invalid
assert_failure
assert_output --partial 'exec: "foobar": executable file not found'
}
@test "plan/proxy invalid schema" {
cd "$TESTDIR"
run "$DAGGER" "do" -p ./plan/proxy/invalid_schema.cue verify
assert_failure
}
@test "plan/proxy invalid value" {
cd "$TESTDIR"
run "$DAGGER" "do" -p ./plan/proxy/invalid_value.cue verify
assert_failure
}
@test "plan/proxy incomplete unix" {
cd "$TESTDIR"
run "$DAGGER" "do" -p ./plan/proxy/incomplete_unix.cue verify
assert_failure
}
@test "plan/proxy incomplete service" {
cd "$TESTDIR"
run "$DAGGER" "do" -p ./plan/proxy/incomplete_service.cue verify
assert_output --partial 'mount "docker" is not concrete'
}
@test "plan/proxy unix" {
cd "$TESTDIR"
"$DAGGER" "do" -p ./plan/proxy/unix.cue verify
}
@test "plan/inputs/directories" {
cd "$TESTDIR"
"$DAGGER" "do" -p ./plan/inputs/directories/valid exists
run "$DAGGER" "do" -p ./plan/inputs/directories/invalid notExists
assert_failure
assert_output --partial 'fasdfsdfs" does not exist'
run "$DAGGER" "do" -p ./plan/inputs/directories/valid conflictingValues
assert_failure
assert_output --partial 'conflicting values "local directory" and "local dfsadf"'
}
@test "plan/inputs/secrets" {
cd "$TESTDIR"
"$DAGGER" "do" -p ./plan/inputs/secrets test valid
"$DAGGER" "do" -p ./plan/inputs/secrets test relative
run "$DAGGER" "do" -p ./plan/inputs/secrets test badCommand
assert_failure
assert_output --partial 'failed: exec: "rtyet": executable file not found'
run "$DAGGER" "do" -p ./plan/inputs/secrets test badArgs
assert_failure
assert_output --partial 'option'
}
@test "plan/with" {
cd "$TESTDIR"
"$DAGGER" "do" --with 'inputs: params: foo:"bar"' -p ./plan/with test params
"$DAGGER" "do" --with 'actions: test: direct: env: FOO: "bar"' -p ./plan/with test direct
run "$DAGGER" "do" --with 'inputs: params: foo:1' -p ./plan/with test params
assert_failure
assert_output --partial "conflicting values string and 1"
run "$DAGGER" "do" -p ./plan/with test params
assert_failure
assert_output --partial "actions.test.params.env.FOO: non-concrete value string"
}
@test "plan/platform" {
cd "$TESTDIR"
# Run with amd64 platform
run "$DAGGER" up ./plan/platform/config_platform_linux_amd64.cue
# Run with arm64 platform
run "$DAGGER" up ./plan/platform/config_platform_linux_arm64.cue
# Run with invalid platform
run "$DAGGER" up ./plan/platform/config_platform_failure_invalid_platform.cue
assert_failure
}