Add simple test environment for core features

Signed-off-by: Solomon Hykes <solomon@dagger.io>
This commit is contained in:
Solomon Hykes 2021-06-17 14:11:10 +00:00 committed by Solomon Hykes
parent 21c76f2873
commit 49277af680
5 changed files with 76 additions and 1 deletions

2
.dagger/env/test-core/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
# dagger state
state/**

View File

@ -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)

27
.dagger/env/test-core/values.yaml vendored Normal file
View File

@ -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

30
tests/core.bats Normal file
View File

@ -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!'
}

View File

@ -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"