tests: add query tests

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
Andrea Luzzardi 2021-04-08 18:31:10 -07:00
parent 43a34f0b04
commit 65ebbc8ecb
3 changed files with 62 additions and 26 deletions

View File

@ -1,3 +0,0 @@
package testing
nonConcrete: string

View File

@ -4,8 +4,18 @@ import "dagger.io/dagger/op"
foo: "value" foo: "value"
bar: "another value" bar: "another value"
computed: {
#up: [ string
op.#FetchContainer & {ref: "busybox"}, #up: [
op.#Exec & {args: ["true"]}, op.#FetchContainer & {ref: "busybox"},
] op.#Exec & {
args: ["sh", "-c", """
printf test > /export
"""]
},
op.#Export & {
source: "/export"
format: "string"
},
]
}

View File

@ -51,10 +51,11 @@ test::cli::newdir() {
"$dagger" "${DAGGER_BINARY_ARGS[@]}" up -d "simple" "$dagger" "${DAGGER_BINARY_ARGS[@]}" up -d "simple"
test::one "CLI: new: verify we have the right plan" --stdout='{ test::one "CLI: new: verify we have the right plan" --stdout='{
foo: "value" "bar": "another value",
bar: "another value" "computed": "test",
"foo": "value"
}' \ }' \
"$dagger" "${DAGGER_BINARY_ARGS[@]}" query -f cue -d "simple" -c "$dagger" "${DAGGER_BINARY_ARGS[@]}" query -f cue -d "simple" -c -f json
} }
test::cli::newgit() { test::cli::newgit() {
@ -89,20 +90,45 @@ test::cli::query() {
test::one "CLI: query: initialize simple" \ test::one "CLI: query: initialize simple" \
"$dagger" "${DAGGER_BINARY_ARGS[@]}" new --plan-dir "$d"/cli/simple simple "$dagger" "${DAGGER_BINARY_ARGS[@]}" new --plan-dir "$d"/cli/simple simple
test::one "CLI: query: concrete" --stdout='{ test::one "CLI: query: before up" --stdout='{
foo: "value" "bar": "another value",
bar: "another value" "foo": "value"
}' \ }' \
"$dagger" "${DAGGER_BINARY_ARGS[@]}" query -f cue -d "simple" -c "$dagger" "${DAGGER_BINARY_ARGS[@]}" query -d "simple"
test::one "CLI: query: concrete should fail" --exit=1 \
"$dagger" "${DAGGER_BINARY_ARGS[@]}" query -d "simple" -c
test::one "CLI: query: target" --stdout='"value"' \ test::one "CLI: query: target" --stdout='"value"' \
"$dagger" "${DAGGER_BINARY_ARGS[@]}" query -f cue -d "simple" foo "$dagger" "${DAGGER_BINARY_ARGS[@]}" query -d "simple" foo
test::one "CLI: query: initialize nonconcrete" \ test::one "CLI: query: compute missing values" \
"$dagger" "${DAGGER_BINARY_ARGS[@]}" new --plan-dir "$d"/cli/nonconcrete nonconcrete "$dagger" "${DAGGER_BINARY_ARGS[@]}" up -d "simple"
test::one "CLI: query: non concrete" --exit=1 \ test::one "CLI: query: all values" --stdout='{
"$dagger" "${DAGGER_BINARY_ARGS[@]}" query -f cue -d "nonconcrete" -c "bar": "another value",
"computed": "test",
"foo": "value"
}' \
"$dagger" "${DAGGER_BINARY_ARGS[@]}" query -d "simple"
test::one "CLI: query: concrete should work" --stdout='{
"bar": "another value",
"computed": "test",
"foo": "value"
}' \
"$dagger" "${DAGGER_BINARY_ARGS[@]}" query -d "simple" -c
test::one "CLI: query --no-computed" --stdout='{
"bar": "another value",
"foo": "value"
}' \
"$dagger" "${DAGGER_BINARY_ARGS[@]}" query -d "simple" --no-computed
test::one "CLI: query: --no-plan" --stdout='{
"computed": "test"
}' \
"$dagger" "${DAGGER_BINARY_ARGS[@]}" query -d "simple" -c --no-plan
} }
test::cli::plan() { test::cli::plan() {
@ -117,19 +143,22 @@ test::cli::plan() {
"$dagger" "${DAGGER_BINARY_ARGS[@]}" new --plan-dir "$d"/cli/simple simple "$dagger" "${DAGGER_BINARY_ARGS[@]}" new --plan-dir "$d"/cli/simple simple
test::one "CLI: plan dir" \ test::one "CLI: plan dir" \
"$dagger" "${DAGGER_BINARY_ARGS[@]}" -d "simple" plan dir "$d"/cli/nonconcrete "$dagger" "${DAGGER_BINARY_ARGS[@]}" -d "simple" plan dir "$d"/cli/simple
test::one "CLI: plan dir: query non-concrete" --exit=1 \ test::one "CLI: plan dir: verify we have the right plan" --stdout='{
"$dagger" "${DAGGER_BINARY_ARGS[@]}" -d "simple" query -c "bar": "another value",
"foo": "value"
}' \
"$dagger" "${DAGGER_BINARY_ARGS[@]}" -d "simple" query
test::one "CLI: plan git" \ test::one "CLI: plan git" \
"$dagger" "${DAGGER_BINARY_ARGS[@]}" -d "simple" plan git https://github.com/samalba/dagger-test.git "$dagger" "${DAGGER_BINARY_ARGS[@]}" -d "simple" plan git https://github.com/samalba/dagger-test.git
test::one "CLI: plan git: verify we have the right plan" --stdout='{ test::one "CLI: plan git: verify we have the right plan" --stdout='{
foo: "value" "bar": "another value",
bar: "another value" "foo": "value"
}' \ }' \
"$dagger" "${DAGGER_BINARY_ARGS[@]}" query -f cue -d "simple" -c "$dagger" "${DAGGER_BINARY_ARGS[@]}" query -d "simple" -c
} }
test::cli::input() { test::cli::input() {