Merge pull request #155 from dagger/stdlib-tests
stdlib: basic tests for alpine go and yarn
This commit is contained in:
commit
2d45895097
43
tests/stdlib/alpine/alpine.cue
Normal file
43
tests/stdlib/alpine/alpine.cue
Normal file
@ -0,0 +1,43 @@
|
||||
package alpine
|
||||
|
||||
import (
|
||||
"dagger.io/dagger"
|
||||
"dagger.io/alpine"
|
||||
)
|
||||
|
||||
TestImageVersion: {
|
||||
image: alpine.#Image & {
|
||||
// install an old version on purpose
|
||||
version: "3.10.6"
|
||||
}
|
||||
|
||||
test: #dagger: compute: [
|
||||
dagger.#Load & {from: image},
|
||||
dagger.#Exec & {
|
||||
args: [
|
||||
"sh",
|
||||
"-ec",
|
||||
"""
|
||||
test "$(cat /etc/alpine-release)" = 3.10.6
|
||||
""",
|
||||
]
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
TestPackageInstall: {
|
||||
image: alpine.#Image & {
|
||||
package: jq: true
|
||||
package: curl: "=~7.74.0"
|
||||
}
|
||||
|
||||
test: #dagger: compute: [
|
||||
dagger.#Load & {from: image},
|
||||
dagger.#Exec & {
|
||||
args: ["jq", "--version"]
|
||||
},
|
||||
dagger.#Exec & {
|
||||
args: ["sh", "-ec", "curl --version | grep -q 7.74.0"]
|
||||
},
|
||||
]
|
||||
}
|
33
tests/stdlib/go/go.cue
Normal file
33
tests/stdlib/go/go.cue
Normal file
@ -0,0 +1,33 @@
|
||||
package go
|
||||
|
||||
import (
|
||||
"dagger.io/dagger"
|
||||
"dagger.io/go"
|
||||
"dagger.io/alpine"
|
||||
)
|
||||
|
||||
TestData: dagger.#Dir
|
||||
|
||||
TestGoBuild: {
|
||||
build: go.#Build & {
|
||||
source: TestData
|
||||
output: "/bin/testbin"
|
||||
}
|
||||
|
||||
test: #dagger: compute: [
|
||||
dagger.#Load & {from: alpine.#Image},
|
||||
dagger.#Exec & {
|
||||
args: [
|
||||
"sh",
|
||||
"-ec",
|
||||
"""
|
||||
test "$(/bin/testbin)" = "hello world"
|
||||
""",
|
||||
]
|
||||
mount: "/bin/testbin": {
|
||||
from: build
|
||||
path: "/bin/testbin"
|
||||
}
|
||||
},
|
||||
]
|
||||
}
|
3
tests/stdlib/go/testdata/go.mod
vendored
Normal file
3
tests/stdlib/go/testdata/go.mod
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
module main
|
||||
|
||||
go 1.14
|
7
tests/stdlib/go/testdata/main.go
vendored
Normal file
7
tests/stdlib/go/testdata/main.go
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
fmt.Println("hello world")
|
||||
}
|
11
tests/stdlib/yarn/testdata/package.json
vendored
Normal file
11
tests/stdlib/yarn/testdata/package.json
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "test",
|
||||
"main": "index.js",
|
||||
"license": {
|
||||
"type": "Apache-2.0",
|
||||
"url": "https://opensource.org/licenses/apache2.0.php"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "mkdir -p ./build && echo output > ./build/test && touch .env && cp .env ./build/"
|
||||
}
|
||||
}
|
35
tests/stdlib/yarn/yarn.cue
Normal file
35
tests/stdlib/yarn/yarn.cue
Normal file
@ -0,0 +1,35 @@
|
||||
package yarn
|
||||
|
||||
import (
|
||||
"dagger.io/dagger"
|
||||
"dagger.io/yarn"
|
||||
"dagger.io/alpine"
|
||||
)
|
||||
|
||||
TestData: dagger.#Dir
|
||||
|
||||
TestYarn: {
|
||||
run: yarn.#Script & {
|
||||
source: TestData
|
||||
}
|
||||
|
||||
test: #dagger: compute: [
|
||||
dagger.#Load & {from: alpine.#Image & {
|
||||
package: bash: "=5.1.0-r0"
|
||||
}},
|
||||
dagger.#Exec & {
|
||||
mount: "/build": from: run
|
||||
args: [
|
||||
"/bin/bash",
|
||||
"--noprofile",
|
||||
"--norc",
|
||||
"-eo",
|
||||
"pipefail",
|
||||
"-c",
|
||||
"""
|
||||
test "$(cat /build/test)" = "output"
|
||||
""",
|
||||
]
|
||||
},
|
||||
]
|
||||
}
|
@ -20,6 +20,17 @@ test::examples() {
|
||||
"$dagger" "${DAGGER_BINARY_ARGS[@]}" compute --input-dir www.source="$d"/../examples/simple "$d"/../examples/simple
|
||||
}
|
||||
|
||||
test::stdlib() {
|
||||
local dagger="$1"
|
||||
|
||||
test::one "stdlib: alpine" \
|
||||
"$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/stdlib/alpine
|
||||
disable test::one "stdlib: yarn (FIXME: performance)" \
|
||||
"$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/stdlib/yarn --input-dir TestData="$d"/stdlib/yarn/testdata
|
||||
disable test::one "stdlib: go (FIXME: performance)" \
|
||||
"$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/stdlib/go --input-dir TestData="$d"/stdlib/go/testdata
|
||||
}
|
||||
|
||||
test::compute(){
|
||||
local dagger="$1"
|
||||
|
||||
@ -251,6 +262,7 @@ test::all(){
|
||||
test::subdir "$dagger"
|
||||
test::dockerbuild "$dagger"
|
||||
|
||||
test::stdlib "$dagger"
|
||||
test::examples "$dagger"
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user