2021-04-14 23:47:46 +02:00
|
|
|
setup() {
|
|
|
|
load 'helpers'
|
|
|
|
|
|
|
|
common_setup
|
|
|
|
}
|
|
|
|
|
2021-05-26 00:14:39 +02:00
|
|
|
@test "dagger init" {
|
|
|
|
run "$DAGGER" init
|
2021-04-14 23:47:46 +02:00
|
|
|
assert_success
|
|
|
|
|
|
|
|
run "$DAGGER" list
|
|
|
|
assert_success
|
2021-05-26 00:14:39 +02:00
|
|
|
refute_output
|
2021-04-14 23:47:46 +02:00
|
|
|
|
2021-05-26 00:14:39 +02:00
|
|
|
run "$DAGGER" init
|
|
|
|
assert_failure
|
|
|
|
}
|
2021-04-14 23:47:46 +02:00
|
|
|
|
2021-05-26 00:14:39 +02:00
|
|
|
@test "dagger new" {
|
|
|
|
run "$DAGGER" new "test"
|
2021-04-14 23:47:46 +02:00
|
|
|
assert_failure
|
|
|
|
|
2021-05-26 00:14:39 +02:00
|
|
|
run "$DAGGER" init
|
|
|
|
assert_success
|
2021-04-14 23:47:46 +02:00
|
|
|
|
2021-05-26 00:14:39 +02:00
|
|
|
run "$DAGGER" list
|
2021-04-14 23:47:46 +02:00
|
|
|
assert_success
|
2021-05-26 00:14:39 +02:00
|
|
|
refute_output
|
2021-04-14 23:47:46 +02:00
|
|
|
|
2021-05-26 00:14:39 +02:00
|
|
|
run "$DAGGER" new "test"
|
2021-04-14 23:47:46 +02:00
|
|
|
assert_success
|
2021-05-26 00:14:39 +02:00
|
|
|
|
|
|
|
run "$DAGGER" list
|
|
|
|
assert_success
|
|
|
|
assert_output --partial "test"
|
|
|
|
|
|
|
|
run "$DAGGER" new "test"
|
|
|
|
assert_failure
|
2021-04-14 23:47:46 +02:00
|
|
|
}
|
|
|
|
|
2021-06-15 18:49:57 +02:00
|
|
|
# create different environments from the same module
|
|
|
|
@test "dagger new: modules" {
|
|
|
|
"$DAGGER" init
|
|
|
|
|
|
|
|
ln -s "$TESTDIR"/cli/input/simple "$DAGGER_WORKSPACE"/plan
|
|
|
|
|
|
|
|
"$DAGGER" new "a" --module "$DAGGER_WORKSPACE"/plan
|
|
|
|
"$DAGGER" new "b" --module "$DAGGER_WORKSPACE"/plan
|
|
|
|
|
|
|
|
"$DAGGER" input -e "a" text "input" "a"
|
|
|
|
"$DAGGER" input -e "b" text "input" "b"
|
|
|
|
|
|
|
|
"$DAGGER" up -e "a"
|
|
|
|
"$DAGGER" up -e "b"
|
|
|
|
|
|
|
|
run "$DAGGER" query -l error -e "a" input -f text
|
|
|
|
assert_success
|
|
|
|
assert_output "a"
|
|
|
|
|
|
|
|
run "$DAGGER" query -l error -e "b" input -f text
|
|
|
|
assert_success
|
|
|
|
assert_output "b"
|
|
|
|
}
|
|
|
|
|
|
|
|
# create different environments from the same module,
|
|
|
|
# using different packages.
|
|
|
|
@test "dagger new: packages" {
|
|
|
|
"$DAGGER" init
|
|
|
|
|
|
|
|
ln -s "$TESTDIR"/cli/packages "$DAGGER_WORKSPACE"/plan
|
|
|
|
|
2021-06-23 16:31:42 +02:00
|
|
|
"$DAGGER" new "a" --module "$DAGGER_WORKSPACE"/plan --package alpha.dagger.io/test/a
|
|
|
|
"$DAGGER" new "b" --module "$DAGGER_WORKSPACE"/plan --package alpha.dagger.io/test/b
|
2021-06-15 18:49:57 +02:00
|
|
|
|
|
|
|
"$DAGGER" up -e "a"
|
|
|
|
"$DAGGER" up -e "b"
|
|
|
|
|
|
|
|
run "$DAGGER" query -l error -e "a" exp -f text
|
|
|
|
assert_success
|
|
|
|
assert_output "a"
|
|
|
|
|
|
|
|
run "$DAGGER" query -l error -e "b" exp -f text
|
|
|
|
assert_success
|
|
|
|
assert_output "b"
|
|
|
|
}
|
|
|
|
|
2021-04-14 23:47:46 +02:00
|
|
|
@test "dagger query" {
|
2021-05-26 00:14:39 +02:00
|
|
|
"$DAGGER" init
|
|
|
|
|
|
|
|
dagger_new_with_plan simple "$TESTDIR"/cli/simple
|
|
|
|
|
2021-04-27 21:07:15 +02:00
|
|
|
run "$DAGGER" query -l error -e "simple"
|
2021-04-14 23:47:46 +02:00
|
|
|
assert_success
|
|
|
|
assert_output '{
|
|
|
|
"bar": "another value",
|
|
|
|
"foo": "value"
|
|
|
|
}'
|
|
|
|
# concrete should fail at this point since we haven't up'd
|
2021-04-27 21:07:15 +02:00
|
|
|
run "$DAGGER" query -e "simple" -c
|
2021-04-14 23:47:46 +02:00
|
|
|
assert_failure
|
|
|
|
|
|
|
|
# target
|
2021-04-27 21:07:15 +02:00
|
|
|
run "$DAGGER" -l error query -e "simple" foo
|
2021-04-14 23:47:46 +02:00
|
|
|
assert_success
|
|
|
|
assert_output '"value"'
|
|
|
|
|
|
|
|
# ensure computed values show up
|
2021-04-27 21:07:15 +02:00
|
|
|
"$DAGGER" up -e "simple"
|
|
|
|
run "$DAGGER" -l error query -e "simple"
|
2021-04-14 23:47:46 +02:00
|
|
|
assert_success
|
|
|
|
assert_output --partial '"computed": "test"'
|
|
|
|
|
|
|
|
# concrete should now work
|
2021-04-27 21:07:15 +02:00
|
|
|
"$DAGGER" query -e "simple" -c
|
2021-04-14 23:47:46 +02:00
|
|
|
|
|
|
|
# --no-computed should yield the same result as before
|
2021-04-27 21:07:15 +02:00
|
|
|
run "$DAGGER" query -l error --no-computed -e "simple"
|
2021-04-14 23:47:46 +02:00
|
|
|
assert_success
|
|
|
|
assert_output '{
|
|
|
|
"bar": "another value",
|
|
|
|
"foo": "value"
|
|
|
|
}'
|
|
|
|
|
|
|
|
# --no-plan should give us only the computed values
|
2021-04-27 21:07:15 +02:00
|
|
|
run "$DAGGER" query -l error --no-plan -e "simple"
|
2021-04-14 23:47:46 +02:00
|
|
|
assert_success
|
|
|
|
assert_output '{
|
|
|
|
"computed": "test"
|
|
|
|
}'
|
|
|
|
}
|
|
|
|
|
2021-04-15 21:22:32 +02:00
|
|
|
@test "dagger input text" {
|
2021-05-26 00:14:39 +02:00
|
|
|
"$DAGGER" init
|
|
|
|
|
|
|
|
dagger_new_with_plan input "$TESTDIR"/cli/input/simple
|
2021-04-14 23:47:46 +02:00
|
|
|
|
2021-04-15 21:47:30 +02:00
|
|
|
# simple input
|
2021-04-27 21:07:15 +02:00
|
|
|
"$DAGGER" input -e "input" text "input" "my input"
|
|
|
|
"$DAGGER" up -e "input"
|
|
|
|
run "$DAGGER" -l error query -e "input" input
|
2021-04-15 21:22:32 +02:00
|
|
|
assert_success
|
|
|
|
assert_output '"my input"'
|
|
|
|
|
2021-04-29 17:07:18 +02:00
|
|
|
# unset simple input
|
|
|
|
"$DAGGER" input -e "input" unset "input"
|
|
|
|
"$DAGGER" up -e "input"
|
|
|
|
run "$DAGGER" -l error query -e "input" input
|
|
|
|
assert_success
|
|
|
|
assert_output 'null'
|
|
|
|
|
2021-04-15 21:47:30 +02:00
|
|
|
# nested input
|
2021-04-27 21:07:15 +02:00
|
|
|
"$DAGGER" input -e "input" text "nested.input" "nested input"
|
|
|
|
"$DAGGER" up -e "input"
|
|
|
|
run "$DAGGER" -l error query -e "input" nested
|
2021-04-15 21:22:32 +02:00
|
|
|
assert_success
|
|
|
|
assert_output '{
|
|
|
|
"input": "nested input"
|
|
|
|
}'
|
2021-04-15 21:47:30 +02:00
|
|
|
|
2021-04-29 17:07:18 +02:00
|
|
|
# unset nested input
|
|
|
|
"$DAGGER" input -e "input" unset "nested.input"
|
|
|
|
"$DAGGER" up -e "input"
|
|
|
|
run "$DAGGER" -l error query -e "input" nested
|
|
|
|
assert_success
|
|
|
|
assert_output 'null'
|
|
|
|
|
2021-04-15 21:47:30 +02:00
|
|
|
# file input
|
2021-04-27 21:07:15 +02:00
|
|
|
"$DAGGER" input -e "input" text "input" -f "$TESTDIR"/cli/input/simple/testdata/input.txt
|
|
|
|
"$DAGGER" up -e "input"
|
|
|
|
run "$DAGGER" -l error query -e "input" input
|
2021-04-15 21:47:30 +02:00
|
|
|
assert_success
|
|
|
|
assert_output '"from file\n"'
|
|
|
|
|
2021-04-29 17:07:18 +02:00
|
|
|
# unset file input
|
|
|
|
"$DAGGER" input -e "input" unset "input"
|
|
|
|
"$DAGGER" up -e "input"
|
|
|
|
run "$DAGGER" -l error query -e "input" input
|
|
|
|
assert_success
|
|
|
|
assert_output 'null'
|
|
|
|
|
2021-04-15 21:47:30 +02:00
|
|
|
# invalid file
|
2021-04-27 21:07:15 +02:00
|
|
|
run "$DAGGER" input -e "input" text "input" -f "$TESTDIR"/cli/input/simple/testdata/notexist
|
2021-04-15 21:47:30 +02:00
|
|
|
assert_failure
|
|
|
|
|
|
|
|
# stdin input
|
2021-04-27 21:07:15 +02:00
|
|
|
echo -n "from stdin" | "$DAGGER" input -e "input" text "input" -f -
|
|
|
|
"$DAGGER" up -e "input"
|
|
|
|
run "$DAGGER" -l error query -e "input" input
|
2021-04-15 21:47:30 +02:00
|
|
|
assert_success
|
|
|
|
assert_output '"from stdin"'
|
2021-04-29 17:07:18 +02:00
|
|
|
|
|
|
|
# unset stdin input
|
|
|
|
"$DAGGER" input -e "input" unset "input"
|
|
|
|
"$DAGGER" up -e "input"
|
|
|
|
run "$DAGGER" -l error query -e "input" input
|
|
|
|
assert_success
|
|
|
|
assert_output 'null'
|
2021-04-15 21:22:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "dagger input json" {
|
2021-05-26 00:14:39 +02:00
|
|
|
"$DAGGER" init
|
|
|
|
|
|
|
|
dagger_new_with_plan input "$TESTDIR"/cli/input/simple
|
2021-04-15 21:22:32 +02:00
|
|
|
|
2021-04-29 17:07:18 +02:00
|
|
|
# simple json
|
2021-04-27 21:07:15 +02:00
|
|
|
"$DAGGER" input -e "input" json "structured" '{"a": "foo", "b": 42}'
|
|
|
|
"$DAGGER" up -e "input"
|
|
|
|
run "$DAGGER" -l error query -e "input" structured
|
2021-04-14 23:47:46 +02:00
|
|
|
assert_success
|
|
|
|
assert_output '{
|
2021-04-15 21:22:32 +02:00
|
|
|
"a": "foo",
|
|
|
|
"b": 42
|
2021-04-14 23:47:46 +02:00
|
|
|
}'
|
2021-04-15 21:47:30 +02:00
|
|
|
|
2021-04-29 17:07:18 +02:00
|
|
|
# unset simple json
|
|
|
|
"$DAGGER" input -e "input" unset "structured"
|
|
|
|
"$DAGGER" up -e "input"
|
|
|
|
run "$DAGGER" -l error query -e "input" structured
|
|
|
|
assert_success
|
|
|
|
assert_output 'null'
|
|
|
|
|
|
|
|
# json from file
|
2021-04-27 21:07:15 +02:00
|
|
|
"$DAGGER" input -e "input" json "structured" -f "$TESTDIR"/cli/input/simple/testdata/input.json
|
|
|
|
"$DAGGER" up -e "input"
|
|
|
|
run "$DAGGER" -l error query -e "input" structured
|
2021-04-15 21:47:30 +02:00
|
|
|
assert_success
|
|
|
|
assert_output '{
|
|
|
|
"a": "from file",
|
|
|
|
"b": 42
|
|
|
|
}'
|
2021-04-29 17:07:18 +02:00
|
|
|
|
|
|
|
# unset json from file
|
|
|
|
"$DAGGER" input -e "input" unset "structured"
|
|
|
|
"$DAGGER" up -e "input"
|
|
|
|
run "$DAGGER" -l error query -e "input" structured
|
|
|
|
assert_success
|
|
|
|
assert_output 'null'
|
2021-04-15 21:22:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "dagger input yaml" {
|
2021-05-26 00:14:39 +02:00
|
|
|
"$DAGGER" init
|
|
|
|
|
|
|
|
dagger_new_with_plan input "$TESTDIR"/cli/input/simple
|
2021-04-15 21:22:32 +02:00
|
|
|
|
2021-04-29 17:07:18 +02:00
|
|
|
# simple yaml
|
2021-04-27 21:07:15 +02:00
|
|
|
"$DAGGER" input -e "input" yaml "structured" '{"a": "foo", "b": 42}'
|
|
|
|
"$DAGGER" up -e "input"
|
|
|
|
run "$DAGGER" -l error query -e "input" structured
|
2021-04-15 21:22:32 +02:00
|
|
|
assert_success
|
|
|
|
assert_output '{
|
|
|
|
"a": "foo",
|
|
|
|
"b": 42
|
|
|
|
}'
|
2021-04-15 21:47:30 +02:00
|
|
|
|
2021-04-29 17:07:18 +02:00
|
|
|
# unset simple yaml
|
|
|
|
"$DAGGER" input -e "input" unset "structured"
|
|
|
|
"$DAGGER" up -e "input"
|
|
|
|
run "$DAGGER" -l error query -e "input" structured
|
|
|
|
assert_success
|
|
|
|
assert_output 'null'
|
|
|
|
|
|
|
|
# yaml from file
|
2021-04-27 21:07:15 +02:00
|
|
|
"$DAGGER" input -e "input" yaml "structured" -f "$TESTDIR"/cli/input/simple/testdata/input.yaml
|
|
|
|
"$DAGGER" up -e "input"
|
|
|
|
run "$DAGGER" -l error query -e "input" structured
|
2021-04-15 21:47:30 +02:00
|
|
|
assert_success
|
|
|
|
assert_output '{
|
|
|
|
"a": "from file",
|
|
|
|
"b": 42
|
|
|
|
}'
|
2021-04-29 17:07:18 +02:00
|
|
|
|
|
|
|
# unset yaml from file
|
|
|
|
"$DAGGER" input -e "input" unset "structured"
|
|
|
|
"$DAGGER" up -e "input"
|
|
|
|
run "$DAGGER" -l error query -e "input" structured
|
|
|
|
assert_success
|
|
|
|
assert_output 'null'
|
2021-04-15 21:22:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "dagger input dir" {
|
2021-05-26 00:14:39 +02:00
|
|
|
"$DAGGER" init
|
|
|
|
|
|
|
|
dagger_new_with_plan input "$TESTDIR"/cli/input/artifact
|
|
|
|
|
|
|
|
# input dir outside the workspace
|
|
|
|
run "$DAGGER" input -e "input" dir "source" /tmp
|
|
|
|
assert_failure
|
2021-04-14 23:47:46 +02:00
|
|
|
|
2021-05-26 00:14:39 +02:00
|
|
|
# input dir inside the workspace
|
|
|
|
cp -R "$TESTDIR"/cli/input/artifact/testdata/ "$DAGGER_WORKSPACE"/testdata
|
|
|
|
"$DAGGER" input -e "input" dir "source" "$DAGGER_WORKSPACE"/testdata
|
2021-04-27 21:07:15 +02:00
|
|
|
"$DAGGER" up -e "input"
|
|
|
|
run "$DAGGER" -l error query -e "input"
|
2021-04-14 23:47:46 +02:00
|
|
|
assert_success
|
|
|
|
assert_output '{
|
|
|
|
"bar": "thisisatest\n",
|
|
|
|
"foo": "bar",
|
|
|
|
"source": {}
|
|
|
|
}'
|
2021-04-29 17:07:18 +02:00
|
|
|
|
|
|
|
# unset dir
|
|
|
|
"$DAGGER" input -e "input" unset "source"
|
|
|
|
"$DAGGER" up -e "input"
|
|
|
|
run "$DAGGER" -l error query -e "input"
|
|
|
|
assert_success
|
|
|
|
assert_output '{
|
|
|
|
"foo": "bar"
|
|
|
|
}'
|
2021-04-15 21:22:32 +02:00
|
|
|
}
|
|
|
|
|
2021-06-21 15:14:18 +02:00
|
|
|
@test "dagger input dir: ignore .dagger" {
|
|
|
|
"$DAGGER" init
|
|
|
|
|
|
|
|
dagger_new_with_plan input "$TESTDIR"/cli/input/ignore
|
|
|
|
|
|
|
|
run [ -d "$TESTDIR"/cli/input/ignore/testdata/.dagger ]
|
|
|
|
assert_success
|
|
|
|
|
|
|
|
cp -R "$TESTDIR"/cli/input/ignore/testdata/ "$DAGGER_WORKSPACE"/testdata
|
|
|
|
"$DAGGER" input -e "input" dir "source" "$DAGGER_WORKSPACE"/testdata
|
|
|
|
"$DAGGER" up -e "input"
|
|
|
|
assert_success
|
|
|
|
}
|
|
|
|
|
2021-04-15 21:22:32 +02:00
|
|
|
@test "dagger input git" {
|
2021-05-26 00:14:39 +02:00
|
|
|
"$DAGGER" init
|
|
|
|
|
|
|
|
dagger_new_with_plan input "$TESTDIR"/cli/input/artifact
|
2021-04-14 23:47:46 +02:00
|
|
|
|
2021-04-29 17:07:18 +02:00
|
|
|
# input git
|
2021-04-27 21:07:15 +02:00
|
|
|
"$DAGGER" input -e "input" git "source" https://github.com/samalba/dagger-test-simple.git
|
|
|
|
"$DAGGER" up -e "input"
|
|
|
|
run "$DAGGER" -l error query -e "input"
|
2021-04-14 23:47:46 +02:00
|
|
|
assert_output '{
|
|
|
|
"bar": "testgit\n",
|
|
|
|
"foo": "bar",
|
|
|
|
"source": {}
|
|
|
|
}'
|
2021-04-29 17:07:18 +02:00
|
|
|
|
|
|
|
# unset input git
|
|
|
|
"$DAGGER" input -e "input" unset "source"
|
|
|
|
"$DAGGER" up -e "input"
|
|
|
|
run "$DAGGER" -l error query -e "input"
|
|
|
|
assert_output '{
|
|
|
|
"foo": "bar"
|
|
|
|
}'
|
2021-04-14 23:47:46 +02:00
|
|
|
}
|
2021-05-26 12:00:59 +02:00
|
|
|
|
|
|
|
@test "dagger input list" {
|
2021-05-26 13:45:10 +02:00
|
|
|
"$DAGGER" init
|
|
|
|
|
|
|
|
dagger_new_with_plan list "$TESTDIR"/cli/input/list
|
2021-05-26 12:00:59 +02:00
|
|
|
"$DAGGER" input text cfg.str "foobar" -e "list"
|
|
|
|
|
|
|
|
out="$("$DAGGER" input list -e "list")"
|
|
|
|
outAll="$("$DAGGER" input list --all -e "list")"
|
|
|
|
|
|
|
|
#note: this is the recommended way to use pipes with bats
|
2021-06-01 15:12:08 +02:00
|
|
|
run bash -c "echo \"$out\" | grep awsConfig.accessKey | grep 'dagger.#Secret' | grep 'AWS access key'"
|
2021-05-26 12:00:59 +02:00
|
|
|
assert_success
|
|
|
|
|
2021-06-01 15:12:08 +02:00
|
|
|
run bash -c "echo \"$out\" | grep cfgInline.source | grep 'dagger.#Artifact' | grep false | grep 'source dir'"
|
2021-05-26 12:00:59 +02:00
|
|
|
assert_success
|
|
|
|
|
|
|
|
run bash -c "echo \"$outAll\" | grep cfg2"
|
|
|
|
assert_failure
|
|
|
|
|
2021-06-01 15:12:08 +02:00
|
|
|
run bash -c "echo \"$out\" | grep cfgInline.strDef | grep '*yolo | string' | grep false"
|
2021-05-26 12:00:59 +02:00
|
|
|
assert_success
|
|
|
|
|
|
|
|
run bash -c "echo \"$out\" | grep cfg.num"
|
|
|
|
assert_failure
|
|
|
|
|
2021-06-01 15:12:08 +02:00
|
|
|
run bash -c "echo \"$outAll\" | grep cfg.num | grep 21 | grep -v int"
|
2021-05-26 12:00:59 +02:00
|
|
|
assert_success
|
|
|
|
|
|
|
|
run bash -c "echo \"$out\" | grep cfg.strSet"
|
|
|
|
assert_failure
|
|
|
|
|
2021-06-01 15:12:08 +02:00
|
|
|
run bash -c "echo \"$outAll\" | grep cfg.strSet | grep pipo"
|
2021-05-26 12:00:59 +02:00
|
|
|
assert_success
|
|
|
|
}
|
2021-05-31 15:56:58 +02:00
|
|
|
|
|
|
|
@test "dagger output list" {
|
|
|
|
"$DAGGER" init
|
|
|
|
|
|
|
|
dagger_new_with_plan list "$TESTDIR"/cli/output/list
|
|
|
|
|
|
|
|
out="$("$DAGGER" output list -e "list")"
|
|
|
|
|
|
|
|
run bash -c "echo \"$out\" | grep cfgInline.url | grep 'http://this.is.a.test/' | grep 'test url description'"
|
|
|
|
assert_success
|
|
|
|
|
|
|
|
run bash -c "echo \"$out\" | grep cfg.url | grep 'http://this.is.a.test/' | grep 'test url description'"
|
|
|
|
assert_success
|
|
|
|
|
|
|
|
run bash -c "echo \"$out\" | grep cfg2.url | grep 'http://this.is.a.test/' | grep 'test url description'"
|
|
|
|
assert_success
|
|
|
|
|
2021-06-01 14:15:02 +02:00
|
|
|
run bash -c "echo \"$out\" | grep cfg.foo | grep '*42 | int'"
|
|
|
|
assert_success
|
2021-05-31 15:56:58 +02:00
|
|
|
|
2021-06-01 14:15:02 +02:00
|
|
|
run bash -c "echo \"$out\" | grep cfg2.bar | grep 'dagger.#Artifact'"
|
2021-05-31 15:56:58 +02:00
|
|
|
assert_success
|
|
|
|
|
2021-06-01 14:15:02 +02:00
|
|
|
run bash -c "echo \"$out\" | grep cfg2.str | grep 'string'"
|
2021-05-31 15:56:58 +02:00
|
|
|
assert_success
|
|
|
|
}
|