tests: move compute tests away

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
Andrea Luzzardi
2021-12-08 14:38:07 -05:00
parent 79f86227f3
commit 1872af9b18
61 changed files with 21 additions and 109 deletions

View File

@@ -0,0 +1 @@
module: ""

View File

@@ -0,0 +1,2 @@
# dagger universe
alpha.dagger.io

View File

@@ -0,0 +1,3 @@
package testing
#up: true

View File

@@ -0,0 +1 @@
module: ""

View File

@@ -0,0 +1,2 @@
# dagger universe
alpha.dagger.io

View File

@@ -0,0 +1,3 @@
package testing
#up: 123

View File

@@ -0,0 +1 @@
module: ""

View File

@@ -0,0 +1,2 @@
# dagger universe
alpha.dagger.io

View File

@@ -0,0 +1,3 @@
package testing
#up: "whatever"

View File

@@ -0,0 +1 @@
module: ""

View File

@@ -0,0 +1,2 @@
# dagger universe
alpha.dagger.io

View File

@@ -0,0 +1,3 @@
package testing
#up: whatever: "wrong"

View File

@@ -0,0 +1 @@
module: ""

View File

@@ -0,0 +1,2 @@
# dagger universe
alpha.dagger.io

View File

@@ -0,0 +1,25 @@
package main
import (
"alpha.dagger.io/alpine"
"alpha.dagger.io/dagger/op"
)
rand: {
string
#up: [
op.#Load & {from: alpine.#Image},
op.#Exec & {
always: true
args: ["sh", "-c", """
tr -dc A-Za-z0-9 </dev/urandom | head -c 13 > /id
"""]
},
op.#Export & {source: "/id"},
]
}
// If rand is executed twice, cue won't validate
ref1: rand
ref2: ref1

View File

@@ -0,0 +1 @@
module: ""

View File

@@ -0,0 +1,2 @@
# dagger universe
alpha.dagger.io

View File

@@ -0,0 +1,6 @@
package testing
// no-op, should not error
empty: {
#up: []
}

View File

@@ -0,0 +1 @@
module: ""

View File

@@ -0,0 +1,2 @@
# dagger universe
alpha.dagger.io

View File

@@ -0,0 +1,19 @@
package testing
import "alpha.dagger.io/dagger/op"
new_prop: "lala"
#new_def: "lala"
new_prop_too: string
#new_def_too: string
#up: [
op.#FetchContainer & {
ref: "busybox"
},
op.#Exec & {
args: ["true"]
dir: "/"
},
]

View File

@@ -0,0 +1 @@
module: ""

View File

@@ -0,0 +1,2 @@
# dagger universe
alpha.dagger.io

View File

@@ -0,0 +1,21 @@
package testing
import "alpha.dagger.io/dagger/op"
foo: {
new_prop: "lala"
#new_def: "lala"
new_prop_too: string
#new_def_too: string
#up: [
op.#FetchContainer & {
ref: "busybox"
},
op.#Exec & {
args: ["true"]
dir: "/"
},
]
}

View File

@@ -0,0 +1 @@
module: ""

View File

@@ -0,0 +1,2 @@
# dagger universe
alpha.dagger.io

View File

@@ -0,0 +1,13 @@
package testing
import "alpha.dagger.io/dagger/op"
#up: [
op.#FetchContainer & {
ref: "busybox"
},
op.#Exec & {
args: ["true"]
dir: "/"
},
]

View File

@@ -0,0 +1 @@
module: ""

View File

@@ -0,0 +1,2 @@
# dagger universe
alpha.dagger.io

View File

@@ -0,0 +1,47 @@
package testing
import "alpha.dagger.io/dagger/op"
A: {
result: string
#up: [
op.#FetchContainer & {
ref: "alpine"
},
op.#Exec & {
args: ["sh", "-c", """
echo '{"result": "from A"}' > /tmp/out
""",
]
dir: "/"
},
op.#Export & {
// Source path in the container
source: "/tmp/out"
format: "json"
},
]
}
B: {
result: string
#up: [
op.#FetchContainer & {
ref: "alpine"
},
op.#Exec & {
args: ["sh", "-c", """
echo "{\\"result\\": \\"dependency \(A.result)\\"}" > /tmp/out
""",
]
dir: "/"
},
op.#Export & {
// Source path in the container
source: "/tmp/out"
format: "json"
},
]
}

View File

@@ -0,0 +1 @@
module: ""

View File

@@ -0,0 +1,2 @@
# dagger universe
alpha.dagger.io

View File

@@ -0,0 +1,47 @@
package testing
import "alpha.dagger.io/dagger/op"
A: {
result: string
#up: [
op.#FetchContainer & {
ref: "alpine"
},
op.#Exec & {
args: ["sh", "-c", """
echo '{"result": "from A"}' > /tmp/out
""",
]
},
op.#Export & {
// Source path in the container
source: "/tmp/out"
format: "json"
},
]
}
B: {
result: string
#up: [
op.#FetchContainer & {
ref: "alpine"
},
op.#Exec & {
env: DATA: A.result
args: ["sh", "-c", """
echo "{\\"result\\": \\"dependency $DATA\\"}" > /tmp/out
""",
]
dir: "/"
},
op.#Export & {
// Source path in the container
source: "/tmp/out"
format: "json"
},
]
}

View File

@@ -0,0 +1 @@
module: ""

View File

@@ -0,0 +1,2 @@
# dagger universe
alpha.dagger.io

View File

@@ -0,0 +1,52 @@
package testing
import (
"encoding/json"
"alpha.dagger.io/dagger/op"
)
A: {
string
#up: [
op.#FetchContainer & {
ref: "alpine"
},
op.#Exec & {
args: ["sh", "-c", """
echo '{"hello": "world"}' > /tmp/out
""",
]
dir: "/"
},
op.#Export & {
// Source path in the container
source: "/tmp/out"
format: "string"
},
]
}
unmarshalled: json.Unmarshal(A)
B: {
result: string
#up: [
op.#FetchContainer & {
ref: "alpine"
},
op.#Exec & {
args: ["sh", "-c", """
echo "{\\"result\\": \\"unmarshalled.hello=\(unmarshalled.hello)\\"}" > /tmp/out
""",
]
dir: "/"
},
op.#Export & {
// Source path in the container
source: "/tmp/out"
format: "json"
},
]
}

View File

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

View File

@@ -0,0 +1 @@
module: ""

View File

@@ -0,0 +1,2 @@
# dagger universe
alpha.dagger.io

View File

@@ -0,0 +1,41 @@
package testing
import (
"alpha.dagger.io/alpine"
"alpha.dagger.io/dagger"
"alpha.dagger.io/dagger/op"
)
TestData: dagger.#Artifact
_expected: """
/src/b.txt
/src/foo:
bar.txt
"""
TestIgnore: {
string
#up: [
op.#Load & {from: alpine.#Image},
op.#Exec & {
args: ["sh", "-c", "ls /src/* > /out.txt"]
mount: "/src": from: TestData
},
op.#Export & {source: "/out.txt"},
op.#Exec & {
args: [
"sh",
"-ec",
"""
cat > /test.txt << EOF
\(_expected)
EOF
test "$(cat /out.txt)" = "$(cat /test.txt)"
""",
]
},
]
}

View File

@@ -0,0 +1,30 @@
plan:
module: .dagger/env/default/plan
name: default
inputs:
TestData:
dir:
path: ./testdata
exclude:
- a.txt
- '*/*.json'
sops:
kms: []
gcp_kms: []
azure_kv: []
hc_vault: []
age:
- recipient: age1gxwmtwahzwdmrskhf90ppwlnze30lgpm056kuesrxzeuyclrwvpsupwtpk
enc: |
-----BEGIN AGE ENCRYPTED FILE-----
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSArcmRHMFByQkZSdGhteHhm
T2pSWW1UcU5LaFJabFJORllydFk3UkVsSHhVCndQZWNUKzVOeUovTTdCR3FmUXpO
c29GQXhpZkxwSmoweWxqZG1CMkcrRGcKLS0tIDhRMTVSc3NXSWIxSm55TGkwT1E1
L0NzY0RIMWNkc3k2WStOUGg4SndNRm8Kk7QSP/8spn1Set08VejVW9k4ZwBFqR0T
Ff/N73yNvo633hrfEJtTkhA/aZYyG9bPJy9s9vRDoNFkdTLSFcYX5g==
-----END AGE ENCRYPTED FILE-----
lastmodified: "2021-06-15T16:27:05Z"
mac: ENC[AES256_GCM,data:XQyAun4JVQxzV9eqte3dpQb8YP9ylWhnW5gLB3avpOZks/CVUN4Ewgob5tA4FB5S4x1Syk/D8ts32nQoEd0HUkdqTMjnGjcXdNiH/iT+k+LrVX30uAZ3JLXmzBfP9WnfJXlKVYaWXWSokiQJmYjXtmotr9rMl7rQeixGZfYcsns=,iv:LyfYlgbiiTh1oapa/h7FUGjd8xGlrD0M9+bxkP5HT6A=,tag:bhw5k2/4zGCxC0nnV4zwDw==,type:str]
pgp: []
encrypted_suffix: secret
version: 3.7.1

0
tests/core/exclude/testdata/a.txt vendored Normal file
View File

0
tests/core/exclude/testdata/b.txt vendored Normal file
View File

View File

View File

View File

@@ -0,0 +1 @@
module: ""

View File

@@ -0,0 +1,2 @@
# dagger universe
alpha.dagger.io

21
tests/core/secrets/invalid/env/env.cue vendored Normal file
View File

@@ -0,0 +1,21 @@
package testing
import (
"alpha.dagger.io/dagger"
"alpha.dagger.io/dagger/op"
"alpha.dagger.io/alpine"
)
mySecret: dagger.#Secret
TestSecrets: #up: [
op.#Load & {
from: alpine.#Image & {
package: bash: "=~5.1"
}
},
op.#Exec & {
env: foo: mySecret
},
]

View File

@@ -0,0 +1 @@
module: ""

View File

@@ -0,0 +1,2 @@
# dagger universe
alpha.dagger.io

View File

@@ -0,0 +1,21 @@
package testing
import (
"alpha.dagger.io/dagger/op"
"alpha.dagger.io/alpine"
)
mySecret: dagger.#Secret
TestString: #up: [
op.#Load & {
from: alpine.#Image & {
package: bash: "=~5.1"
}
},
op.#Exec & {
mount: "/secret": secret: mySecret
args: ["true"]
},
]

View File

@@ -0,0 +1 @@
module: ""

View File

@@ -0,0 +1,2 @@
# dagger universe
alpha.dagger.io

View File

@@ -0,0 +1,32 @@
package testing
import (
"alpha.dagger.io/dagger"
"alpha.dagger.io/dagger/op"
"alpha.dagger.io/alpine"
)
mySecret: dagger.#Secret
TestSecrets: #up: [
op.#Load & {
from: alpine.#Image & {
package: bash: "=~5.1"
}
},
op.#Exec & {
mount: "/secret": secret: mySecret
args: [
"/bin/bash",
"--noprofile",
"--norc",
"-eo",
"pipefail",
"-c",
#"""
test "$(cat /secret)" = "SecretValue"
"""#,
]
},
]