@@ -38,6 +38,7 @@ import (
3838 dwv2 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
3939 controllerv1alpha1 "github.com/devfile/devworkspace-operator/apis/controller/v1alpha1"
4040 "github.com/devfile/devworkspace-operator/pkg/conditions"
41+ "github.com/devfile/devworkspace-operator/pkg/constants"
4142)
4243
4344var _ = Describe ("BackupCronJobReconciler" , func () {
@@ -253,6 +254,25 @@ var _ = Describe("BackupCronJobReconciler", func() {
253254 jobList := & batchv1.JobList {}
254255 Expect (fakeClient .List (ctx , jobList , & client.ListOptions {Namespace : dw .Namespace })).To (Succeed ())
255256 Expect (jobList .Items ).To (HaveLen (1 ))
257+ job := jobList .Items [0 ]
258+ Expect (job .Labels [constants .DevWorkspaceIDLabel ]).To (Equal ("id-recent" ))
259+ Expect (job .Spec .Template .Spec .ServiceAccountName ).To (Equal ("devworkspace-job-runner-id-recent" ))
260+ container := job .Spec .Template .Spec .Containers [0 ]
261+ expectedEnvs := []corev1.EnvVar {
262+ {Name : "DEVWORKSPACE_NAME" , Value : "dw-recent" },
263+ {Name : "DEVWORKSPACE_NAMESPACE" , Value : "ns-a" },
264+ {Name : "WORKSPACE_ID" , Value : "id-recent" },
265+ {Name : "BACKUP_SOURCE_PATH" , Value : "/workspace/id-recent/projects" },
266+ {Name : "DEVWORKSPACE_BACKUP_REGISTRY" , Value : "fake-registry" },
267+ {Name : "PODMAN_PUSH_OPTIONS" , Value : "--tls-verify=false" },
268+ }
269+ Expect (container .Env ).Should (ContainElements (expectedEnvs ), "container env vars should include vars neeeded for backup" )
270+
271+ expectedVolumeMounts := []corev1.VolumeMount {
272+ {MountPath : "/workspace" , Name : "workspace-data" },
273+ {MountPath : "/var/lib/containers" , Name : "build-storage" },
274+ }
275+ Expect (container .VolumeMounts ).Should (ContainElements (expectedVolumeMounts ), "container volume mounts should include mounts needed for backup" )
256276 })
257277
258278 It ("does not create a Job when the DevWorkspace was stopped beyond time range" , func () {
0 commit comments