diff --git a/tests/cli/input/main.cue b/tests/cli/input/main.cue new file mode 100644 index 00000000..ee315aa6 --- /dev/null +++ b/tests/cli/input/main.cue @@ -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" + } + ] +} diff --git a/tests/cli/input/testdata/testfile b/tests/cli/input/testdata/testfile new file mode 100644 index 00000000..20495ffb --- /dev/null +++ b/tests/cli/input/testdata/testfile @@ -0,0 +1 @@ +thisisatest diff --git a/tests/test-cli.sh b/tests/test-cli.sh index 31b750fb..ebb221f4 100644 --- a/tests/test-cli.sh +++ b/tests/test-cli.sh @@ -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":{}}' +}