Add test on AWS s3

Signed-off-by: Tom Chauveau <tom.chauveau@epitech.eu>
This commit is contained in:
Tom Chauveau 2021-04-22 19:14:17 +02:00
parent 3e2b46bf3a
commit d5aa68fe2b
3 changed files with 97 additions and 0 deletions

View File

@ -37,3 +37,9 @@ setup() {
"$DAGGER" compute "$TESTDIR"/stdlib/kubernetes/helm --input-dir kubeconfig=~/.kube --input-dir TestHelmSimpleChart.deploy.chartSource="$TESTDIR"/stdlib/kubernetes/helm/testdata/mychart "$DAGGER" compute "$TESTDIR"/stdlib/kubernetes/helm --input-dir kubeconfig=~/.kube --input-dir TestHelmSimpleChart.deploy.chartSource="$TESTDIR"/stdlib/kubernetes/helm/testdata/mychart
} }
@test "stdlib: s3" {
skip_unless_secrets_available "$TESTDIR"/stdlib/aws/inputs.yaml
"$DAGGER" compute "$TESTDIR"/stdlib/aws/s3 --input-yaml "$TESTDIR"/stdlib/aws/inputs.yaml
}

View File

@ -0,0 +1,24 @@
package s3
import (
"dagger.io/aws"
"dagger.io/aws/s3"
)
TestConfig: awsConfig: aws.#Config & {
region: "us-east-2"
}
bucket: "dagger-ci"
content: "A simple test sentence"
TestS3UploadFile: {
deploy: s3.#Put & {
config: TestConfig.awsConfig
sourceInline: content
target: "s3://\(bucket)/test.txt"
}
verify: #VerifyS3
}

View File

@ -0,0 +1,67 @@
package s3
import (
"dagger.io/aws"
"dagger.io/alpine"
"dagger.io/dagger/op"
)
#List: {
// AWS Config
config: aws.#Config
// Target S3 URL (e.g. s3://<bucket-name>/<path>/<sub-path>)
target?: string
// Export folder
export: "/contents"
// Script
aws.#Script & {
code: """
aws s3 ls \(target) > /contents
"""
}
}
#VerifyS3: {
lists: #List & {
config: TestConfig.awsConfig
target: "s3://\(bucket)"
}
#CheckFiles:
"""
grep -q test.txt /test
"""
test: #up: [
op.#Load & {
from: alpine.#Image & {
package: bash: "~5.1"
}
},
op.#WriteFile & {
dest: "/test"
content: lists.out
},
op.#WriteFile & {
dest: "/checkFiles.sh"
content: #CheckFiles
},
op.#Exec & {
always: true
args: [
"/bin/bash",
"--noprofile",
"--norc",
"-eo",
"pipefail",
"/checkFiles.sh",
]
},
]
}