diff --git a/.dagger/env/test-core/.gitignore b/.dagger/env/test-core/.gitignore new file mode 100644 index 00000000..01ec19b0 --- /dev/null +++ b/.dagger/env/test-core/.gitignore @@ -0,0 +1,2 @@ +# dagger state +state/** diff --git a/.dagger/env/test-core/plan/test-core.cue b/.dagger/env/test-core/plan/test-core.cue new file mode 100644 index 00000000..60122bbb --- /dev/null +++ b/.dagger/env/test-core/plan/test-core.cue @@ -0,0 +1,11 @@ +package testcore + +import ( + "dagger.io/dagger" +) + +name: string | *"world" @dagger(input) +message: "Hello, \(name)!" @dagger(output) + +dir: dagger.#Artifact @dagger(input) +samedir: dir @dagger(output) diff --git a/.dagger/env/test-core/values.yaml b/.dagger/env/test-core/values.yaml new file mode 100644 index 00000000..41ba947a --- /dev/null +++ b/.dagger/env/test-core/values.yaml @@ -0,0 +1,27 @@ +plan: + module: .dagger/env/test-core/plan +name: test-core +inputs: + dir: + dir: + path: ./tests +sops: + kms: [] + gcp_kms: [] + azure_kv: [] + hc_vault: [] + age: + - recipient: age1gxwmtwahzwdmrskhf90ppwlnze30lgpm056kuesrxzeuyclrwvpsupwtpk + enc: | + -----BEGIN AGE ENCRYPTED FILE----- + YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBhOW1rUy9vNFBDaXRDUHJu + ZVZYM1FucVorRDdUcmRaYmg3eTlTNzhhYWdjCndWZWxhZnhCZG4xZU9JQ1VyMXdR + OHY0TS81bk9FL2JuUEhuTmcxa29ORGcKLS0tIGxJUzNrZmRBNHZGRFY2Z01QK2JP + MlM1Ukdqbi9SQ0pqTi9FZ3MxN2E2QmsKHwd7P6KHPVdynOoto1jf3G4+5+vf87wU + HX1KD7Od5wRdBwn7r3OS8mdvuNIYpJDUb5YDrfjQypt020ohLocNiA== + -----END AGE ENCRYPTED FILE----- + lastmodified: "2021-06-17T14:07:53Z" + mac: ENC[AES256_GCM,data:afYut7wdvsJQgxlBg6NEV6DWk8vPi81mZgQAuWb4oe4WJeI1T9cYdtjOHPlmIpjqb86VQHJ29YTzektei2+k+VBawQxcsvefK7X1QboJTfMKLfsiug4qzNWjc7JZDvTb6dsDFM1U96gjSoAIVwdLMnucbu3681Fd7qSQgqNS61Q=,iv:ZQDHzXp0RJcUI4RtOVjdepV8zTa2kIHQhAltLkudDck=,tag:AnSFi1mKrEuXSqE4R+g7dw==,type:str] + pgp: [] + encrypted_suffix: secret + version: 3.7.1 diff --git a/tests/core.bats b/tests/core.bats new file mode 100644 index 00000000..542c9eae --- /dev/null +++ b/tests/core.bats @@ -0,0 +1,30 @@ +# Test core Dagger features & types + +setup() { + load 'helpers' + + common_setup + + # Use native Dagger environment here + unset DAGGER_WORKSPACE +} + +@test "core: inputs" { + # List available inputs + run dagger -e test-core input list + assert_success + assert_output --partial 'name' + assert_output --partial 'dir' + + # Set text input + dagger -e test-core input text name Bob + run dagger -e test-core up + assert_success + assert_output --partial 'Hello, Bob!' + + # Unset text input + dagger -e test-core input unset name + run dagger -e test-core up + assert_success + assert_output --partial 'Hello, world!' +} diff --git a/tests/helpers.bash b/tests/helpers.bash index 6eeca33a..e4f231c9 100644 --- a/tests/helpers.bash +++ b/tests/helpers.bash @@ -27,6 +27,11 @@ dagger_new_with_plan() { } +# dagger helper to execute the right binary +dagger() { + "${DAGGER}" "$@" +} + skip_unless_secrets_available() { local inputFile="$1" sops exec-file "$inputFile" echo > /dev/null 2>&1 || skip "$inputFile cannot be decrypted" @@ -38,4 +43,4 @@ skip_unless_local_kube() { else skip "local kubernetes cluster not available" fi -} \ No newline at end of file +}