tests: split integration tests

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
Andrea Luzzardi
2021-04-01 18:46:08 -07:00
parent 896d303f4a
commit b229119a3d
16 changed files with 394 additions and 345 deletions

View File

@@ -0,0 +1,51 @@
package testing
A: {
result: string
#compute: [
{
do: "fetch-container"
ref: "alpine"
},
{
do: "exec"
args: ["sh", "-c", """
echo '{"result": "from A"}' > /tmp/out
""",
]
dir: "/"
},
{
do: "export"
// Source path in the container
source: "/tmp/out"
format: "json"
},
]
}
B: {
result: string
#compute: [
{
do: "fetch-container"
ref: "alpine"
},
{
do: "exec"
args: ["sh", "-c", """
echo "{\\"result\\": \\"dependency \(A.result)\\"}" > /tmp/out
""",
]
dir: "/"
},
{
do: "export"
// Source path in the container
source: "/tmp/out"
format: "json"
},
]
}

View File

@@ -0,0 +1,52 @@
package testing
A: {
result: string
#compute: [
{
do: "fetch-container"
ref: "alpine"
},
{
do: "exec"
args: ["sh", "-c", """
echo '{"result": "from A"}' > /tmp/out
""",
]
dir: "/"
},
{
do: "export"
// Source path in the container
source: "/tmp/out"
format: "json"
},
]
}
B: {
result: string
#compute: [
{
do: "fetch-container"
ref: "alpine"
},
{
do: "exec"
env: DATA: A.result
args: ["sh", "-c", """
echo "{\\"result\\": \\"dependency $DATA\\"}" > /tmp/out
""",
]
dir: "/"
},
{
do: "export"
// Source path in the container
source: "/tmp/out"
format: "json"
},
]
}

View File

@@ -0,0 +1,55 @@
package testing
import "encoding/json"
A: {
string
#compute: [
{
do: "fetch-container"
ref: "alpine"
},
{
do: "exec"
args: ["sh", "-c", """
echo '{"hello": "world"}' > /tmp/out
""",
]
dir: "/"
},
{
do: "export"
// Source path in the container
source: "/tmp/out"
format: "string"
},
]
}
unmarshalled: json.Unmarshal(A)
B: {
result: string
#compute: [
{
do: "fetch-container"
ref: "alpine"
},
{
do: "exec"
args: ["sh", "-c", """
echo "{\\"result\\": \\"unmarshalled.hello=\(unmarshalled.hello)\\"}" > /tmp/out
""",
]
dir: "/"
},
{
do: "export"
// Source path in the container
source: "/tmp/out"
format: "json"
},
]
}

View File

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

View File

@@ -0,0 +1,2 @@
a.txt
*/*.json

0
tests/compute/ignore/testdata/a.txt vendored Normal file
View File

0
tests/compute/ignore/testdata/b.txt vendored Normal file
View File

View File

View File