2021-12-09 00:24:16 +01:00
|
|
|
setup() {
|
|
|
|
load 'helpers'
|
|
|
|
|
|
|
|
common_setup
|
|
|
|
}
|
|
|
|
|
2022-03-09 03:34:47 +01:00
|
|
|
@test "plan/do: action sanity checks" {
|
|
|
|
run "$DAGGER" "do" -p ./plan/do/actions.cue not exist
|
|
|
|
assert_failure
|
|
|
|
assert_output --partial "not found"
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "plan/do: dynamic tasks - fails to find tasks" {
|
2022-03-08 00:53:50 +01:00
|
|
|
# Europa loader handles the cwd differently, therefore we need to CD into the tree at or below the parent of cue.mod
|
|
|
|
cd "$TESTDIR"
|
2022-03-08 17:47:17 +01:00
|
|
|
run "$DAGGER" "do" -p ./plan/do/dynamic_tasks.cue test b
|
2022-03-08 00:53:50 +01:00
|
|
|
# No output because of weirdness with dynamic tasks, which causes it to fail
|
2022-03-08 17:41:34 +01:00
|
|
|
refute_output --partial "actions.test.b"
|
2022-03-08 00:53:50 +01:00
|
|
|
}
|
|
|
|
|
2022-03-09 03:34:47 +01:00
|
|
|
@test "plan/do: dynamic tasks - fails to run tasks" {
|
2022-03-08 00:53:50 +01:00
|
|
|
run "$DAGGER" "do" -p ./plan/do/dynamic_tasks.cue "test"
|
2022-03-08 17:41:34 +01:00
|
|
|
refute_output --partial 'actions.test.b.y'
|
2022-03-08 00:53:50 +01:00
|
|
|
}
|
|
|
|
|
2022-03-09 03:34:47 +01:00
|
|
|
@test "plan/do: don't run unspecified tasks" {
|
2022-03-08 17:41:34 +01:00
|
|
|
run "$DAGGER" "do" -p ./plan/do/do_not_run_unspecified_tasks.cue test
|
2022-03-08 00:53:50 +01:00
|
|
|
assert_output --partial "actions.test.one.script"
|
|
|
|
assert_output --partial "actions.test.three.script"
|
|
|
|
assert_output --partial "actions.test.two.script"
|
|
|
|
assert_output --partial "actions.image"
|
|
|
|
assert_output --partial "actions.test.one"
|
|
|
|
assert_output --partial "actions.test.two"
|
|
|
|
assert_output --partial "actions.test.three"
|
|
|
|
assert_output --partial "actions.test.one.export"
|
2022-03-08 17:56:39 +01:00
|
|
|
assert_output --partial 'client.filesystem."./test_do".write'
|
|
|
|
refute_output --partial "actions.notMe"
|
2022-03-08 17:59:07 +01:00
|
|
|
refute_output --partial 'client.filesystem."./dependent_do".write'
|
2022-03-08 00:53:50 +01:00
|
|
|
}
|
|
|
|
|
2022-03-11 00:11:55 +01:00
|
|
|
@test "plan/do: nice error message for 0.1.0 projects" {
|
2022-03-10 23:15:50 +01:00
|
|
|
run "$DAGGER" "do" -p ./plan/do/error_message_for_0.1_projects.cue
|
2022-03-11 00:11:55 +01:00
|
|
|
assert_output --partial "attempting to load a dagger 0.1.0 project."
|
|
|
|
|
|
|
|
run "$DAGGER" "do" -p ./plan/do/error_message_for_0.1_projects.cue test
|
|
|
|
assert_output --partial "attempting to load a dagger 0.1.0 project."
|
2022-03-10 23:15:50 +01:00
|
|
|
}
|
|
|
|
|
2021-12-14 22:29:20 +01:00
|
|
|
@test "plan/hello" {
|
2021-12-09 22:32:26 +01:00
|
|
|
# Europa loader handles the cwd differently, therefore we need to CD into the tree at or below the parent of cue.mod
|
2021-12-09 23:59:48 +01:00
|
|
|
cd "$TESTDIR"
|
2022-02-22 22:04:54 +01:00
|
|
|
"$DAGGER" "do" -p ./plan/hello-europa test
|
2021-12-11 00:06:14 +01:00
|
|
|
}
|
|
|
|
|
2022-03-07 14:12:39 +01:00
|
|
|
@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
|
2022-03-08 22:45:28 +01:00
|
|
|
assert_failure
|
|
|
|
assert_output --partial 'conflicting values "local directory" and "local foobar"'
|
2022-03-07 14:12:39 +01:00
|
|
|
|
|
|
|
run "$DAGGER" "do" -p ./usage test excluded
|
2022-03-08 22:45:28 +01:00
|
|
|
assert_failure
|
|
|
|
assert_line --partial 'test.log: no such file or directory'
|
2022-03-07 14:12:39 +01:00
|
|
|
|
|
|
|
run "$DAGGER" "do" -p ./usage test notExists
|
2022-03-08 22:45:28 +01:00
|
|
|
assert_failure
|
|
|
|
assert_output --partial 'test.json: no such file or directory'
|
2022-03-07 14:12:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "plan/client/filesystem/read/fs/not_exists" {
|
|
|
|
cd "$TESTDIR/plan/client/filesystem/read/fs/not_exists"
|
|
|
|
|
|
|
|
run "$DAGGER" "do" -p . test
|
2022-03-08 22:45:28 +01:00
|
|
|
assert_failure
|
|
|
|
assert_output --partial 'path "/foobar" does not exist'
|
2022-03-07 14:12:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@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
|
2022-03-08 22:45:28 +01:00
|
|
|
assert_failure
|
|
|
|
assert_output --partial 'test.log: no such file or directory'
|
2022-03-07 14:12:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@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"
|
|
|
|
|
2022-03-09 13:29:26 +01:00
|
|
|
"$DAGGER" "do" -p ./plan/client/env/usage.cue test
|
2022-03-07 14:12:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "plan/client/env not exists" {
|
|
|
|
cd "${TESTDIR}"
|
|
|
|
|
2022-03-09 13:29:26 +01:00
|
|
|
run "$DAGGER" "do" -p ./plan/client/env/usage.cue test
|
2022-03-07 14:12:39 +01:00
|
|
|
assert_failure
|
2022-03-09 13:29:26 +01:00
|
|
|
assert_output --regexp "environment variable \"TEST_(STRING|SECRET)\" not set"
|
2022-03-07 14:12:39 +01:00
|
|
|
}
|
|
|
|
|
2022-03-09 13:29:26 +01:00
|
|
|
@test "plan/client/env concrete" {
|
2022-03-07 14:12:39 +01:00
|
|
|
cd "${TESTDIR}"
|
|
|
|
|
|
|
|
export TEST_FAIL="foobar"
|
|
|
|
|
2022-03-09 13:29:26 +01:00
|
|
|
run "$DAGGER" "do" -p ./plan/client/env/concrete.cue test
|
2022-03-07 14:12:39 +01:00
|
|
|
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
|
2021-12-14 22:29:20 +01:00
|
|
|
assert_failure
|
2022-03-08 22:45:28 +01:00
|
|
|
assert_output --partial 'exec: "foobar": executable file not found'
|
2021-12-17 22:41:09 +01:00
|
|
|
}
|
2021-12-22 15:03:54 +01:00
|
|
|
|
2022-01-04 20:20:01 +01:00
|
|
|
@test "plan/with" {
|
2022-01-04 18:25:32 +01:00
|
|
|
cd "$TESTDIR"
|
2022-03-08 22:45:28 +01:00
|
|
|
"$DAGGER" "do" --with 'actions: params: foo:"bar"' -p ./plan/with test params
|
2022-02-22 22:04:54 +01:00
|
|
|
"$DAGGER" "do" --with 'actions: test: direct: env: FOO: "bar"' -p ./plan/with test direct
|
2022-01-31 01:08:16 +01:00
|
|
|
|
2022-03-08 22:45:28 +01:00
|
|
|
run "$DAGGER" "do" --with 'actions: params: foo:1' -p ./plan/with test params
|
2022-01-04 19:32:26 +01:00
|
|
|
assert_failure
|
|
|
|
assert_output --partial "conflicting values string and 1"
|
2022-01-31 01:08:16 +01:00
|
|
|
|
2022-02-22 22:04:54 +01:00
|
|
|
run "$DAGGER" "do" -p ./plan/with test params
|
2022-01-04 19:32:26 +01:00
|
|
|
assert_failure
|
2022-02-22 22:04:54 +01:00
|
|
|
assert_output --partial "actions.test.params.env.FOO: non-concrete value string"
|
2021-12-23 19:09:26 +01:00
|
|
|
}
|
|
|
|
|
2021-12-23 15:28:36 +01:00
|
|
|
@test "plan/platform" {
|
|
|
|
cd "$TESTDIR"
|
|
|
|
|
|
|
|
# Run with amd64 platform
|
2022-03-09 19:45:46 +01:00
|
|
|
run "$DAGGER" "do" -p./plan/platform/config_platform_linux_amd64.cue verify
|
2021-12-23 15:28:36 +01:00
|
|
|
|
|
|
|
# Run with arm64 platform
|
2022-03-09 19:45:46 +01:00
|
|
|
run "$DAGGER" "do" -p./plan/platform/config_platform_linux_arm64.cue verify
|
2021-12-23 15:28:36 +01:00
|
|
|
|
|
|
|
# Run with invalid platform
|
2022-03-09 19:45:46 +01:00
|
|
|
run "$DAGGER" "do" -p./plan/platform/config_platform_failure_invalid_platform.cue verify
|
2021-12-23 15:28:36 +01:00
|
|
|
assert_failure
|
2022-01-31 01:08:16 +01:00
|
|
|
}
|