From 590a1b231f80d0d8bc7e13f26fa9ce2c52fc3b0f Mon Sep 17 00:00:00 2001 From: Pavel Sviderski Date: Sun, 13 Apr 2025 12:43:23 +1000 Subject: [PATCH] chore(volumes): e2e test when volume doesn't exist --- test/e2e/service_test.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/test/e2e/service_test.go b/test/e2e/service_test.go index db94b946..f7175923 100644 --- a/test/e2e/service_test.go +++ b/test/e2e/service_test.go @@ -611,6 +611,36 @@ func TestDeployment(t *testing.T) { assert.Equal(t, c.Machines[2].Name, machine.Machine.Name, "Containers should only be on machine #2") }) + // Deployments with volumes. + t.Run("fails when volume doesn't exist", func(t *testing.T) { + t.Parallel() + + name := "test-nonexistent-volume" + spec := api.ServiceSpec{ + Name: name, + Container: api.ContainerSpec{ + Image: "portainer/pause:latest", + VolumeMounts: []api.VolumeMount{ + { + VolumeName: "non-existent-volume", + ContainerPath: "/data", + }, + }, + }, + Volumes: []api.VolumeSpec{ + { + Name: "non-existent-volume", + Type: api.VolumeTypeVolume, + }, + }, + } + + d := deploy.NewDeployment(cli, spec, nil) + _, err := d.Run(ctx) + require.Error(t, err, "Deployment should fail when volume doesn't exist") + require.Contains(t, err.Error(), "volume 'non-existent-volume' not found") + }) + // TODO: test deployments with unreachable machines. See https://github.com/psviderski/uncloud/issues/29. }