1010 test implementation
Signed-off-by: Guillaume de Rouville <guillaume.derouville@gmail.com>
This commit is contained in:
15
docs/learn/tests/dev-cue-package/script.sh
Normal file
15
docs/learn/tests/dev-cue-package/script.sh
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
|
||||
mkdir test
|
||||
|
||||
cat > test/source.cue << EOF
|
||||
package test
|
||||
|
||||
import (
|
||||
"github.com/tjovicic/gcpcloudrun"
|
||||
)
|
||||
|
||||
run: gcpcloudrun.#Run
|
||||
EOF
|
||||
|
||||
dagger new staging -p ./test
|
41
docs/learn/tests/dev-cue-package/source.cue
Normal file
41
docs/learn/tests/dev-cue-package/source.cue
Normal file
@@ -0,0 +1,41 @@
|
||||
package gcpcloudrun
|
||||
|
||||
import (
|
||||
"alpha.dagger.io/dagger"
|
||||
"alpha.dagger.io/docker"
|
||||
"alpha.dagger.io/gcp"
|
||||
"alpha.dagger.io/gcp/cloudrun"
|
||||
"alpha.dagger.io/gcp/gcr"
|
||||
)
|
||||
|
||||
#Run: {
|
||||
// Source code of the sample application
|
||||
src: dagger.#Artifact & dagger.#Input
|
||||
|
||||
// GCR full image name
|
||||
imageRef: string & dagger.#Input
|
||||
|
||||
image: docker.#Build & {
|
||||
source: src
|
||||
}
|
||||
|
||||
gcpConfig: gcp.#Config
|
||||
|
||||
creds: gcr.#Credentials & {
|
||||
config: gcpConfig
|
||||
}
|
||||
|
||||
push: docker.#Push & {
|
||||
target: imageRef
|
||||
source: image
|
||||
auth: {
|
||||
username: creds.username
|
||||
secret: creds.secret
|
||||
}
|
||||
}
|
||||
|
||||
deploy: cloudrun.#Service & {
|
||||
config: gcpConfig
|
||||
image: push.ref
|
||||
}
|
||||
}
|
@@ -141,4 +141,23 @@ setup() {
|
||||
# Prepare and run cloudformation cleanup
|
||||
dagger -e cloudformation input text stackRemoval.stackName $stackName
|
||||
dagger -e cloudformation up
|
||||
}
|
||||
}
|
||||
|
||||
@test "doc-1010-dev-cue-package" {
|
||||
setup_example_sandbox ""
|
||||
|
||||
# Initializing workspace
|
||||
mkdir workspace
|
||||
cd workspace
|
||||
|
||||
# Writing the package
|
||||
dagger init
|
||||
mkdir -p cue.mod/pkg/github.com/tjovicic/gcpcloudrun
|
||||
cp $CODEBLOC_SRC/dev-cue-package/source.cue cue.mod/pkg/github.com/tjovicic/gcpcloudrun/source.cue
|
||||
cp $CODEBLOC_SRC/dev-cue-package/script.sh .
|
||||
|
||||
chmod +x script.sh
|
||||
./script.sh
|
||||
run dagger up -e staging
|
||||
assert_output --partial "environment=staging input=run.gcpConfig.serviceKey"
|
||||
}
|
||||
|
Reference in New Issue
Block a user