chore: cleanup compose-basic test

This commit is contained in:
Pavel Sviderski
2025-04-21 12:49:44 +10:00
parent 45497fd20c
commit 5fce84d33c
3 changed files with 46 additions and 8 deletions
+33
View File
@@ -0,0 +1,33 @@
package e2e
import (
"context"
"errors"
"testing"
"github.com/psviderski/uncloud/pkg/api"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func removeServices(t *testing.T, cli api.ServiceClient, names ...string) {
ctx := context.Background()
for _, name := range names {
err := cli.RemoveService(ctx, name)
if !errors.Is(err, api.ErrNotFound) {
assert.NoError(t, err)
}
}
}
func removeVolumes(t *testing.T, cli api.VolumeClient, names ...string) {
ctx := context.Background()
volumes, err := cli.ListVolumes(ctx, &api.VolumeFilter{Names: names})
require.NoError(t, err)
for _, vol := range volumes {
err = cli.RemoveVolume(ctx, vol.MachineID, vol.Volume.Name, false)
assert.NoError(t, err)
}
}
+4 -8
View File
@@ -22,18 +22,15 @@ func TestComposeDeployment(t *testing.T) {
cli, err := c.Machines[0].Connect(ctx)
require.NoError(t, err)
t.Run("basic", func(t *testing.T) {
t.Run("basic with published ports", func(t *testing.T) {
t.Parallel()
name := "basic"
name := "test-compose-basic"
t.Cleanup(func() {
err := cli.RemoveService(ctx, name)
if !errors.Is(err, api.ErrNotFound) {
require.NoError(t, err)
}
removeServices(t, cli, name)
})
project, err := compose.LoadProject(ctx, []string{"fixtures/basic-compose.yaml"})
project, err := compose.LoadProject(ctx, []string{"fixtures/compose-basic.yaml"})
require.NoError(t, err)
deploy, err := compose.NewDeployment(ctx, cli, project)
@@ -58,7 +55,6 @@ func TestComposeDeployment(t *testing.T) {
"BOOL": "true",
"EMPTY": "",
},
// TODO: resolve image digest and substitute the image with the image@digest.
Image: "portainer/pause:3.9",
},
Ports: []api.PortSpec{
+9
View File
@@ -0,0 +1,9 @@
services:
test-compose-basic:
image: portainer/pause:3.9
environment:
VAR: "value"
BOOL: "true"
EMPTY: ""
x-ports:
- basic.example.com:80/https