2021-04-14 23:47:46 +02:00
|
|
|
setup() {
|
|
|
|
load 'helpers'
|
|
|
|
|
|
|
|
common_setup
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "dagger list" {
|
|
|
|
run "$DAGGER" list
|
|
|
|
assert_success
|
|
|
|
assert_output ""
|
|
|
|
|
|
|
|
"$DAGGER" new --plan-dir "$TESTDIR"/cli/simple simple
|
|
|
|
|
|
|
|
run "$DAGGER" list
|
|
|
|
assert_success
|
|
|
|
assert_output --partial "simple"
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "dagger new --plan-dir" {
|
|
|
|
run "$DAGGER" list
|
|
|
|
assert_success
|
|
|
|
assert_output ""
|
|
|
|
|
|
|
|
"$DAGGER" new --plan-dir "$TESTDIR"/cli/simple simple
|
|
|
|
|
|
|
|
# duplicate name
|
|
|
|
run "$DAGGER" new --plan-dir "$TESTDIR"/cli/simple simple
|
|
|
|
assert_failure
|
|
|
|
|
|
|
|
# verify the plan works
|
2021-04-27 21:07:15 +02:00
|
|
|
"$DAGGER" up -e "simple"
|
2021-04-14 23:47:46 +02:00
|
|
|
|
|
|
|
# verify we have the right plan
|
2021-04-27 21:07:15 +02:00
|
|
|
run "$DAGGER" query -f cue -e "simple" -c -f json
|
2021-04-14 23:47:46 +02:00
|
|
|
assert_success
|
|
|
|
assert_output --partial '{
|
|
|
|
"bar": "another value",
|
|
|
|
"computed": "test",
|
|
|
|
"foo": "value"
|
|
|
|
}'
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "dagger new --plan-git" {
|
|
|
|
"$DAGGER" new --plan-git https://github.com/samalba/dagger-test.git simple
|
2021-04-27 21:07:15 +02:00
|
|
|
"$DAGGER" up -e "simple"
|
|
|
|
run "$DAGGER" query -f cue -e "simple" -c
|
2021-04-14 23:47:46 +02:00
|
|
|
assert_success
|
|
|
|
assert_output --partial '{
|
|
|
|
foo: "value"
|
|
|
|
bar: "another value"
|
|
|
|
}'
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "dagger query" {
|
|
|
|
"$DAGGER" new --plan-dir "$TESTDIR"/cli/simple 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"
|
|
|
|
}'
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "dagger plan" {
|
|
|
|
"$DAGGER" new --plan-dir "$TESTDIR"/cli/simple simple
|
|
|
|
|
|
|
|
# plan dir
|
2021-04-27 21:07:15 +02:00
|
|
|
"$DAGGER" -e "simple" plan dir "$TESTDIR"/cli/simple
|
|
|
|
run "$DAGGER" -e "simple" query
|
2021-04-14 23:47:46 +02:00
|
|
|
assert_success
|
|
|
|
assert_output --partial '"foo": "value"'
|
|
|
|
|
|
|
|
# plan git
|
2021-04-27 21:07:15 +02:00
|
|
|
"$DAGGER" -e "simple" plan git https://github.com/samalba/dagger-test.git
|
|
|
|
run "$DAGGER" -e "simple" query
|
2021-04-14 23:47:46 +02:00
|
|
|
assert_success
|
|
|
|
assert_output --partial '"foo": "value"'
|
|
|
|
}
|
|
|
|
|
2021-04-15 21:22:32 +02:00
|
|
|
@test "dagger input text" {
|
|
|
|
"$DAGGER" new --plan-dir "$TESTDIR"/cli/input/simple "input"
|
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" {
|
|
|
|
"$DAGGER" new --plan-dir "$TESTDIR"/cli/input/simple "input"
|
|
|
|
|
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" {
|
|
|
|
"$DAGGER" new --plan-dir "$TESTDIR"/cli/input/simple "input"
|
|
|
|
|
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" {
|
|
|
|
"$DAGGER" new --plan-dir "$TESTDIR"/cli/input/artifact "input"
|
2021-04-14 23:47:46 +02:00
|
|
|
|
2021-04-29 17:07:18 +02:00
|
|
|
# input dir
|
2021-04-27 21:07:15 +02:00
|
|
|
"$DAGGER" input -e "input" dir "source" "$TESTDIR"/cli/input/artifact/testdata
|
|
|
|
"$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
|
|
|
}
|
|
|
|
|
|
|
|
@test "dagger input git" {
|
|
|
|
"$DAGGER" new --plan-dir "$TESTDIR"/cli/input/artifact "input"
|
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-04-19 22:44:21 +02:00
|
|
|
|
|
|
|
@test "dagger input scan" {
|
|
|
|
"$DAGGER" new --plan-dir "$TESTDIR"/cli/input/scan "scan"
|
2021-04-29 17:07:18 +02:00
|
|
|
|
|
|
|
# TODO "scan" option isn't implemented
|
2021-04-27 21:07:15 +02:00
|
|
|
run "$DAGGER" input scan -e "input"
|
2021-04-19 22:44:21 +02:00
|
|
|
assert_success
|
|
|
|
}
|