test: implemented cli tests for input git,dir

Signed-off-by: Sam Alba <sam.alba@gmail.com>
This commit is contained in:
Sam Alba 2021-04-02 16:40:41 -07:00
parent d3fc31ab57
commit b12a3bf45f
3 changed files with 54 additions and 0 deletions

25
tests/cli/input/main.cue Normal file
View File

@ -0,0 +1,25 @@
package testing
import (
"dagger.io/llb"
"dagger.io/dagger"
)
source: dagger.#Artifact
foo: "bar"
bar: {
string
#compute: [
llb.#FetchContainer & {ref: "busybox"},
llb.#Exec & {
args: ["cp", "/source/testfile", "/out"],
mount: "/source": from: source
},
llb.#Export & {
format: "string"
source: "/out"
}
]
}

1
tests/cli/input/testdata/testfile vendored Normal file
View File

@ -0,0 +1 @@
thisisatest

View File

@ -12,6 +12,7 @@ test::cli() {
test::cli::newgit "$dagger"
test::cli::query "$dagger"
test::cli::plan "$dagger"
test::cli::input "$dagger"
}
test::cli::list() {
@ -130,3 +131,30 @@ test::cli::plan() {
}' \
"$dagger" "${DAGGER_BINARY_ARGS[@]}" query -d "simple" -c
}
test::cli::input() {
local dagger="$1"
# Create temporary store
local DAGGER_STORE
DAGGER_STORE="$(mktemp -d -t dagger-store-XXXXXX)"
export DAGGER_STORE
test::one "CLI: new input" \
"$dagger" "${DAGGER_BINARY_ARGS[@]}" new --plan-dir "$d"/cli/input "input"
test::one "CLI: up: missing input" \
"$dagger" "${DAGGER_BINARY_ARGS[@]}" up -d "input" --stdout='{"foo":"bar"}'
test::one "CLI: plan dir" \
"$dagger" "${DAGGER_BINARY_ARGS[@]}" input -d "input" dir "source" ./tests/cli/input/testdata
test::one "CLI: up: input is set with input dir" \
"$dagger" "${DAGGER_BINARY_ARGS[@]}" up -d "input" --stdout='{"bar":"thisisatest\n","foo":"bar","source":{}}'
test::one "CLI: plan dir" \
"$dagger" "${DAGGER_BINARY_ARGS[@]}" input -d "input" git "source" https://github.com/samalba/dagger-test-simple.git
test::one "CLI: up: input is set with input git" \
"$dagger" "${DAGGER_BINARY_ARGS[@]}" up -d "input" --stdout='{"bar":"testgit\n","foo":"bar","source":{}}'
}