mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-26 11:03:34 +00:00
chore: cleanup compose-basic test
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
@@ -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{
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user