mirror of
https://github.com/sablierapp/sablier.git
synced 2025-12-28 07:56:35 +01:00
* refactor: move app/theme to pkg/theme * refactor * wip * use dockerindocker * add providertest * wip * wip * test(docker): get state now uses dind container to test against a real provider * test(docker): move to docker_test package * refactor(docker): create container_inspect.go * test(docker): add more dind test * test(docker): event test now use docker in docker * refactor: remove unused instance type props * refactor test docker * fix instance list sort * stabilize test * remove testcontainers custom config
46 lines
1.1 KiB
Go
46 lines
1.1 KiB
Go
package docker_test
|
|
|
|
import (
|
|
"context"
|
|
"github.com/docker/docker/api/types/container"
|
|
"github.com/neilotoole/slogt"
|
|
"github.com/sablierapp/sablier/pkg/provider/docker"
|
|
"gotest.tools/v3/assert"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestDockerClassicProvider_NotifyInstanceStopped(t *testing.T) {
|
|
if testing.Short() {
|
|
t.Skip("skipping test in short mode.")
|
|
}
|
|
|
|
ctx, cancel := context.WithTimeout(t.Context(), 30*time.Second)
|
|
defer cancel()
|
|
dind := setupDinD(t, ctx)
|
|
p, err := docker.NewDockerClassicProvider(ctx, dind.client, slogt.New(t))
|
|
assert.NilError(t, err)
|
|
|
|
c, err := dind.CreateMimic(ctx, MimicOptions{})
|
|
assert.NilError(t, err)
|
|
|
|
inspected, err := dind.client.ContainerInspect(ctx, c.ID)
|
|
assert.NilError(t, err)
|
|
|
|
err = dind.client.ContainerStart(ctx, c.ID, container.StartOptions{})
|
|
assert.NilError(t, err)
|
|
|
|
<-time.After(1 * time.Second)
|
|
|
|
waitC := make(chan string)
|
|
go p.NotifyInstanceStopped(ctx, waitC)
|
|
|
|
err = dind.client.ContainerStop(ctx, c.ID, container.StopOptions{})
|
|
assert.NilError(t, err)
|
|
|
|
name := <-waitC
|
|
|
|
// Docker container name is prefixed with a slash, but we don't use it
|
|
assert.Equal(t, "/"+name, inspected.Name)
|
|
}
|