tests: migrate ops test to bats
Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
33
tests/ops/push-container/inputs.yaml
Normal file
33
tests/ops/push-container/inputs.yaml
Normal file
@@ -0,0 +1,33 @@
|
||||
registry:
|
||||
username: ENC[AES256_GCM,data:8AH6p9WHidanCA==,iv:ezThCQJv+bVBf8SdfSa2HFoP+eu6IZMPl5xvMOGDcps=,tag:mzR7xTKeQNDvkyd2Dm3AKw==,type:str]
|
||||
token: ENC[AES256_GCM,data:68d31b3EfnQJofIt6j+iBCtDyLOBWjFqvVmejyDjIOh8oBXP,iv:PMghC2nd7jqAzrQzm/PW1YdbE0VAbEBkK0/Ri1WwduI=,tag:0JH4WbcJHvgzF4VIK4deBg==,type:str]
|
||||
sops:
|
||||
kms: []
|
||||
gcp_kms: []
|
||||
azure_kv: []
|
||||
hc_vault: []
|
||||
lastmodified: '2021-03-18T22:59:59Z'
|
||||
mac: ENC[AES256_GCM,data:3++nHOAJaYFCEuUXim4/gOsG1ZVWt8Ab88qaqHM6jpCA2gLSyADWpB5iQfU9bM7Sq3PgCcWd5+mDHxl5Q8r9fiozrS025OLtsn7qQQQ84WaiFz9Y4Trsbe4EJXNpxYDXjLZEkEtkKs4/Dl+y2Ey3nVyIWKZEX9cPogJ64zfFS9Q=,iv:jvSwxJ8Of2Nfp1ijKItOraDO8aS6aGHQKFY61kF8JS8=,tag:I+AWPIZsPeXU30zxbgq2eQ==,type:str]
|
||||
pgp:
|
||||
- created_at: '2021-03-18T22:59:59Z'
|
||||
enc: |
|
||||
-----BEGIN PGP MESSAGE-----
|
||||
|
||||
hQIMAzqVY590vudzAQ//etnfnpfCo9rAkctR+Fwg/7VdVL3Rov+6gnyjUnoN1BS1
|
||||
8jnBF/86AZ7uK89dTcTZCsK1hKPxeYg1kJTKpA+zfDORupzTWcMrRyjwNk5wQ2Vg
|
||||
N1adUwFsBQpk8WptpsU/ro6+3yH+Nn35begs6hP2fH/EQ9XOxw5gY0kp0AFjGaKJ
|
||||
tRZVrr3f2hpLESo6LILRO97UXZiGcwTn5onslECL92260cU1nqEQp+ESK7XrdYIG
|
||||
99oM3eXEraKw4WuQDaDE6U135aUl6vIJWD1JZzyr3RW3+5O9pn5rpN3Wc0TbDR6+
|
||||
9Fs/TjuA1h5eJzbt+lkA74BtxPOBv9O7HJnWJpXjiG0VUGHdFXoq5Tr5Ol68RQxa
|
||||
BWe7IfTO6FHN0xOl1dY7cn5jtf+xlFjL86s9OkrJUFa9lbQx8L/QPCeA2Xiu4tpW
|
||||
+wTSel13k8Uv/JSGgLwSohW6N4XTQYdxPkO+a1V08adwFBXaGgqxfg0rNehcS5fp
|
||||
y3TEq84cOlBsaI+rYpnOTPEajtYWfTe8WFf+lBOn1vZ9EiupjZtefGX2MIWPXoaK
|
||||
kVBgRvzjp4/BY68yRvdi5sZFd2nakl+DOXzouuFbzsOkxL3o9FA9aCVsXtFqqzSG
|
||||
Hvq4ZJ5ivXf6vQf+s7Tgc4qxW2CQwIPZVkHhQossrWgtkQ4WDAyzfhF0YuhEnpLS
|
||||
XgGNLr82LMVmempaJd7GfAR2nwGnLUTYny1KoiW/1ie6DPwLZBX/UxPOplaS5wYH
|
||||
Xd3gV3smg5xZ7/rfvzKTzJ1a5yH6D3xI05UtnUWdqojONcXS9NS+P7RArngJwSs=
|
||||
=m0OS
|
||||
-----END PGP MESSAGE-----
|
||||
fp: 6CB37404020B5F0A0B41B5BB225EBAB0B936AC65
|
||||
unencrypted_suffix: _unencrypted
|
||||
version: 3.6.1
|
132
tests/ops/push-container/main.cue
Normal file
132
tests/ops/push-container/main.cue
Normal file
@@ -0,0 +1,132 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"dagger.io/dagger/op"
|
||||
"dagger.io/alpine"
|
||||
)
|
||||
|
||||
TestPushContainer: {
|
||||
// Generate a random number
|
||||
random: {
|
||||
string
|
||||
#up: [
|
||||
op.#Load & {from: alpine.#Image},
|
||||
op.#Exec & {
|
||||
args: ["sh", "-c", "echo -n $RANDOM > /rand"]
|
||||
},
|
||||
op.#Export & {
|
||||
source: "/rand"
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
// Push an image with a random tag
|
||||
push: {
|
||||
ref: "daggerio/ci-test:\(random)"
|
||||
#up: [
|
||||
op.#WriteFile & {
|
||||
content: random
|
||||
dest: "/rand"
|
||||
},
|
||||
op.#PushContainer & {
|
||||
"ref": ref
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
// Pull the image back
|
||||
pull: #up: [
|
||||
op.#FetchContainer & {
|
||||
ref: push.ref
|
||||
},
|
||||
]
|
||||
|
||||
// Check the content
|
||||
check: #up: [
|
||||
op.#Load & {from: alpine.#Image},
|
||||
op.#Exec & {
|
||||
args: [
|
||||
"sh", "-c", #"""
|
||||
test "$(cat /src/rand)" = "\#(random)"
|
||||
"""#,
|
||||
]
|
||||
mount: "/src": from: pull
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
// Ensures image metadata is preserved in a push
|
||||
TestPushContainerMetadata: {
|
||||
// Generate a random number
|
||||
random: {
|
||||
string
|
||||
#up: [
|
||||
op.#Load & {from: alpine.#Image},
|
||||
op.#Exec & {
|
||||
args: ["sh", "-c", "echo -n $RANDOM > /rand"]
|
||||
},
|
||||
op.#Export & {
|
||||
source: "/rand"
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
// `docker build` using an `ENV` and push the image
|
||||
push: {
|
||||
ref: "daggerio/ci-test:\(random)-dockerbuild"
|
||||
#up: [
|
||||
op.#DockerBuild & {
|
||||
dockerfile: #"""
|
||||
FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d
|
||||
ENV CHECK \#(random)
|
||||
"""#
|
||||
},
|
||||
op.#PushContainer & {
|
||||
"ref": ref
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
// Pull the image down and make sure the ENV is preserved
|
||||
check: #up: [
|
||||
op.#FetchContainer & {
|
||||
ref: push.ref
|
||||
},
|
||||
op.#Exec & {
|
||||
args: [
|
||||
"sh", "-c", #"""
|
||||
env
|
||||
test "$CHECK" = "\#(random)"
|
||||
"""#,
|
||||
]
|
||||
},
|
||||
]
|
||||
|
||||
// Do a FetchContainer followed by a PushContainer, make sure
|
||||
// the ENV is preserved
|
||||
pullPush: {
|
||||
ref: "daggerio/ci-test:\(random)-pullpush"
|
||||
|
||||
#up: [
|
||||
op.#FetchContainer & {
|
||||
ref: push.ref
|
||||
},
|
||||
op.#PushContainer & {
|
||||
"ref": ref
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
pullPushCheck: #up: [
|
||||
op.#FetchContainer & {
|
||||
ref: pullPush.ref
|
||||
},
|
||||
op.#Exec & {
|
||||
args: [
|
||||
"sh", "-c", #"""
|
||||
test "$CHECK" = "\#(random)"
|
||||
"""#,
|
||||
]
|
||||
},
|
||||
]
|
||||
}
|
Reference in New Issue
Block a user