From 42e91c0a30b2bf3edf5c3b7d616e908933680d7d Mon Sep 17 00:00:00 2001 From: Sam Alba Date: Wed, 26 May 2021 12:00:59 +0200 Subject: [PATCH] test: implemented tests for input list Signed-off-by: Sam Alba --- tests/cli.bats | 33 ++++++++++++++++++++++++++ tests/cli/input/list/main.cue | 44 +++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 tests/cli/input/list/main.cue diff --git a/tests/cli.bats b/tests/cli.bats index df4d8de8..103c10e6 100644 --- a/tests/cli.bats +++ b/tests/cli.bats @@ -285,3 +285,36 @@ setup() { "foo": "bar" }' } + +@test "dagger input list" { + "$DAGGER" new --plan-dir "$TESTDIR"/cli/input/list "list" + "$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 + run bash -c "echo \"$out\" | grep awsConfig.accessKey | grep '#Secret' | grep false" + assert_success + + run bash -c "echo \"$out\" | grep cfgInline.source | grep '#Artifact' | grep false | grep 'source dir'" + assert_success + + run bash -c "echo \"$outAll\" | grep cfg2" + assert_failure + + run bash -c "echo \"$out\" | grep cfgInline.strDef | grep string | grep 'yolo (default)' | grep false" + assert_success + + run bash -c "echo \"$out\" | grep cfg.num" + assert_failure + + run bash -c "echo \"$outAll\" | grep cfg.num | grep int" + assert_success + + run bash -c "echo \"$out\" | grep cfg.strSet" + assert_failure + + run bash -c "echo \"$outAll\" | grep cfg.strSet | grep string | grep pipo" + assert_success +} diff --git a/tests/cli/input/list/main.cue b/tests/cli/input/list/main.cue new file mode 100644 index 00000000..30d08eee --- /dev/null +++ b/tests/cli/input/list/main.cue @@ -0,0 +1,44 @@ +package main + +import ( + "dagger.io/dagger" + "dagger.io/aws" +) + +awsConfig: aws.#Config & { + // force region + region: "us-east-1" +} + +#A: { + // source dir + source: dagger.#Artifact @dagger(input) + sourceNotInput: dagger.#Artifact + + // a secret + key: dagger.#Secret @dagger(input) + keyNotInput: dagger.#Secret + + // a string + str: string @dagger(input) + strSet: "pipo" @dagger(input) + strDef: *"yolo" | string @dagger(input) + + // a number + num: int | *42 @dagger(input) + numNotInput: int + + // aws config + cfg: awsConfig +} + +cfgInline: { + #A +} + +cfg: #A & { + // force this key + num: 21 +} + +cfg2: cfg