1004 test implementation

Signed-off-by: Guillaume de Rouville <guillaume.derouville@gmail.com>
This commit is contained in:
Guillaume de Rouville 2021-08-13 01:47:59 +02:00
parent ad2f9b3f17
commit 82d45985a5
7 changed files with 94 additions and 32 deletions

View File

@ -68,7 +68,7 @@ Although not strictly necessary, for an optimal development experience, we recom
If you are new to Cue, we recommend keeping the following resources in browser tabs: If you are new to Cue, we recommend keeping the following resources in browser tabs:
The unofficial but excellent [Cuetorials](https://cuetorials.com/overview/foundations/) in a browser tab, to look up Cue concepts as they appear. - The unofficial but excellent [Cuetorials](https://cuetorials.com/overview/foundations/) in a browser tab, to look up Cue concepts as they appear.
- The official [Cue interactive sandbox](https://cuelang.org/play) for easy experimentation. - The official [Cue interactive sandbox](https://cuelang.org/play) for easy experimentation.
@ -130,15 +130,7 @@ In Dagger terms, this component has two essential properties:
Let's write the corresponding Cue code to a new file in our package: Let's write the corresponding Cue code to a new file in our package:
```cue title="todoapp/multibucket/source.cue" ```cue file=./tests/multibucket/source.cue title="todoapp/cue.mod/multibucket/source.cue"
package multibucket
import (
"alpha.dagger.io/dagger"
)
// Source code of the sample application
src: dagger.#Artifact & dagger.#Input
``` ```
This code defines a component at the key `src` and specifies that it is both an artifact and an input. This code defines a component at the key `src` and specifies that it is both an artifact and an input.
@ -147,17 +139,7 @@ This code defines a component at the key `src` and specifies that it is both an
The second component of our plan is the Yarn package built from the app source code: The second component of our plan is the Yarn package built from the app source code:
```cue title="todoapp/multibucket/yarn.cue" ```cue file=./tests/multibucket/yarn.cue title="todoapp/cue.mod/multibucket/yarn.cue"
package multibucket
import (
"alpha.dagger.io/js/yarn"
)
// Build the source code using Yarn
app: yarn.#Package & {
source: src
}
``` ```
Let's break it down: Let's break it down:
@ -176,17 +158,7 @@ _FIXME_: this section is not yet available because the [Amazon S3 package](https
The third component of our plan is the Netlify site to which the app will be deployed: The third component of our plan is the Netlify site to which the app will be deployed:
```cue title="todoapp/multibucket/netlify.cue" ```cue file=./tests/multibucket/netlify.cue title="todoapp/cue.mod/multibucket/netlify.cue"
package multibucket
import (
"alpha.dagger.io/netlify"
)
// Netlify site
site: "netlify": netlify.#Site & {
contents: app.build
}
``` ```
This component is very similar to the previous one: This component is very similar to the previous one:

View File

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

View File

@ -0,0 +1,28 @@
plan:
package: ./multibucket
name: multibucket
inputs:
site.netlify.account.token:
secret: ENC[AES256_GCM,data:e5cILcdqbaFdz6ZMM4sNYrChQS+VSMJTZA9cJ0kPvNEDlQj2n7ldlBeO9A==,iv:4SlRRlXyJ8/9ewAPXJ9KdhdVo4FrvVeRwSip2FfMTIM=,tag:JdxkVTR6SOLgzHUWtoSjyw==,type:str]
site.netlify.name:
text: dagger-test-doc-102
sops:
kms: []
gcp_kms: []
azure_kv: []
hc_vault: []
age:
- recipient: age1gxwmtwahzwdmrskhf90ppwlnze30lgpm056kuesrxzeuyclrwvpsupwtpk
enc: |
-----BEGIN AGE ENCRYPTED FILE-----
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBOVFI4NU40NXF1Um4vR1No
MTByOC9HVWJYUCtzYUc4WGh2UG1EQnJCSm5FCnFrZ1BaMEZJLzBIRUVTUUdhWWRv
N2xRYTR4NlhwclBYME9ZZ3JQejJoUFkKLS0tIDEwa0dXbVhzRWMrMFc3U0FtaEdr
RERQRVp2VjR3K0VwQlZRWEJrQUNpNkUK78CsKmOJp1kKUcytprs0SKLLuo0YDucp
oLuxQQd0X3/8x2c/YfJ3R15e1EQDC73HjSXDbhlgOScR9bxGVqn36A==
-----END AGE ENCRYPTED FILE-----
lastmodified: "2021-08-12T23:19:07Z"
mac: ENC[AES256_GCM,data:9jc3lwlbsJ6CdiSBF4ALNiv/zD7Rv5ZodftuEQpZuJVEpjJCKSq3C7LNyJKxV7fTg/tZ+RDx/q+x0xN9reRRrmvUCsbmLRL2h20rrfsVj3npCSkRiQFcmoHd6ULjf/kbkgUanLt8YmncDzJqNTQfafCxTo1RY3+U2WH/QSIIebQ=,iv:dcXQsq5de6LElOoqvGfs7nmHELkoTs0jddeY3vf4fJg=,tag:j0Eeu5NrNyhBYUzMwarj+w==,type:str]
pgp: []
encrypted_suffix: secret
version: 3.7.1

View File

@ -26,4 +26,36 @@ setup() {
# Check output # Check output
run curl $url run curl $url
assert_output --partial "My Todo app" assert_output --partial "My Todo app"
}
@test "doc-1004-first-env" {
setup_example_sandbox "doc"
# Follow tutorial
mkdir multibucket
cp $CODEBLOC_SRC/multibucket/source.cue multibucket
cp $CODEBLOC_SRC/multibucket/yarn.cue multibucket
cp $CODEBLOC_SRC/multibucket/netlify.cue multibucket
dagger doc alpha.dagger.io/netlify
dagger doc alpha.dagger.io/js/yarn
# Initialize new env
dagger new 'multibucket' -p ./multibucket
# Check inputs
dagger input list -e multibucket
# Copy corresponding env
cp -r $CODEBLOC_SRC/.dagger/env/multibucket .dagger/env/
# Add missing src input
dagger -e multibucket input dir src .
# Run test
dagger -e multibucket up
url=$(dagger -e multibucket query -f text site.netlify.deployUrl)
# Check output :
run curl $url
assert_output --partial "./static/css/main.9149988f.chunk.css"
} }

View File

@ -0,0 +1,10 @@
package multibucket
import (
"alpha.dagger.io/netlify"
)
// Netlify site
site: "netlify": netlify.#Site & {
contents: app.build
}

View File

@ -0,0 +1,8 @@
package multibucket
import (
"alpha.dagger.io/dagger"
)
// Source code of the sample application
src: dagger.#Artifact & dagger.#Input

View File

@ -0,0 +1,10 @@
package multibucket
import (
"alpha.dagger.io/js/yarn"
)
// Build the source code using Yarn
app: yarn.#Package & {
source: src
}