Move tests plan from dagger dir to universe

Signed-off-by: Tom Chauveau <tom.chauveau@epitech.eu>
This commit is contained in:
Tom Chauveau
2021-06-24 21:01:17 +02:00
parent 36cf20ae2d
commit c99e39ec9c
69 changed files with 215 additions and 166 deletions

View File

@@ -0,0 +1,31 @@
package kustomize
import (
"encoding/yaml"
"dagger.io/dagger"
)
TestKustomize: {
testdata: dagger.#Artifact
// Run Kustomize
kustom: #Kustomize & {
source: testdata
kustomization: yaml.Marshal({
resources: ["deployment.yaml", "pod.yaml"]
images: [{
name: "nginx"
newTag: "v1"
}]
replicas: [{
name: "nginx-deployment"
count: 2
}]
})
}
// Verify kustomization generation
verify: #VerifyKustomize & {
source: kustom
}
}

View File

@@ -0,0 +1,22 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx-deployment
spec:
replicas: 1
template:
metadata:
name: nginx-deployment
labels:
app: nginx-deployment
spec:
containers:
- name: nginx-deployment
image: nginx
imagePullPolicy: IfNotPresent
restartPolicy: Always
selector:
matchLabels:
app: nginx-deployment

View File

@@ -0,0 +1,12 @@
apiVersion: v1
kind: Pod
metadata:
name: test-pod
labels:
app: test-pod
spec:
containers:
- name: test-pod
image: nginx
imagePullPolicy: IfNotPresent
restartPolicy: Always

View File

@@ -0,0 +1,72 @@
package kustomize
import (
"alpha.dagger.io/dagger/op"
"alpha.dagger.io/dagger"
"alpha.dagger.io/alpine"
)
#VerifyKustomize: {
source: dagger.#Artifact
#up: [
op.#Load & {
from: alpine.#Image & {
package: bash: "=~5.1"
}
},
// Check files
op.#Exec & {
always: true
args: [
"sh", "-c", "test $(ls /source | wc -l) = 1",
]
mount: "/source": from: source
},
// Check image tag kustomization
op.#Exec & {
always: true
args: [
"sh", "-c", #"""
grep -q "\- image: nginx:v1" /source/result.yaml
"""#,
]
mount: "/source": from: source
},
// Check replicas kustomization
op.#Exec & {
always: true
args: [
"sh", "-c", #"""
grep -q "replicas: 2" /source/result.yaml
"""#,
]
mount: "/source": from: source
},
// Check pod merge by kustomization
op.#Exec & {
always: true
args: [
"sh", "-c", #"""
grep -q "kind: Pod" /source/result.yaml
"""#,
]
mount: "/source": from: source
},
// Check pod name
op.#Exec & {
always: true
args: [
"sh", "-c", #"""
grep -q "name: test-pod" /source/result.yaml
"""#,
]
mount: "/source": from: source
},
]
}