Skip to content

Commit

Permalink
chore: dockerCompose constructor functions return interface instead
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonyunicorn committed Jan 31, 2025
1 parent a43edc8 commit 9f7a5ca
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions modules/compose/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,11 @@ func WithProfiles(profiles ...string) ComposeStackOption {
return ComposeProfiles(profiles)
}

func NewDockerCompose(filePaths ...string) (*dockerCompose, error) {
func NewDockerCompose(filePaths ...string) (ComposeStack, error) {
return NewDockerComposeWith(WithStackFiles(filePaths...))
}

func NewDockerComposeWith(opts ...ComposeStackOption) (*dockerCompose, error) {
func NewDockerComposeWith(opts ...ComposeStackOption) (ComposeStack, error) {
composeOptions := composeStackOptions{
Identifier: uuid.New().String(),
temporaryPaths: make(map[string]bool),
Expand Down
8 changes: 4 additions & 4 deletions modules/compose/compose_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func TestDockerComposeAPI_TestcontainersLabelsArePresent(t *testing.T) {
c, err := compose.ServiceContainer(context.Background(), serviceName)
require.NoError(t, err, "compose.ServiceContainer()")

inspect, err := compose.dockerClient.ContainerInspect(ctx, c.GetContainerID())
inspect, err := compose.(*dockerCompose).dockerClient.ContainerInspect(ctx, c.GetContainerID())
require.NoError(t, err, "dockerClient.ContainerInspect()")

for key, label := range testcontainers.GenericLabels() {
Expand Down Expand Up @@ -475,7 +475,7 @@ services:
require.NoError(t, compose.Down(context.Background(), RemoveOrphans(true), RemoveVolumes(true), RemoveImagesLocal), "compose.Down()")

// check files where removed
f, err := os.Stat(compose.configs[0])
f, err := os.Stat(compose.(*dockerCompose).configs[0])
require.Error(t, err, "File should be removed")
require.True(t, os.IsNotExist(err), "File should be removed")
require.Nil(t, f, "File should be removed")
Expand Down Expand Up @@ -643,7 +643,7 @@ func TestDockerComposeAPIVolumesDeletedOnDown(t *testing.T) {
volumeListFilters := filters.NewArgs()
// the "mydata" identifier comes from the "testdata/docker-compose-volume.yml" file
volumeListFilters.Add("name", identifier+"_mydata")
volumeList, err := compose.dockerClient.VolumeList(ctx, volume.ListOptions{Filters: volumeListFilters})
volumeList, err := compose.(*dockerCompose).dockerClient.VolumeList(ctx, volume.ListOptions{Filters: volumeListFilters})
require.NoError(t, err, "compose.dockerClient.VolumeList()")

require.Empty(t, volumeList.Volumes, "Volumes are not cleaned up")
Expand Down Expand Up @@ -694,7 +694,7 @@ func testNameHash(name string) StackIdentifier {
}

// cleanup is a helper function that schedules the compose stack to be stopped when the test ends.
func cleanup(t *testing.T, compose *dockerCompose) {
func cleanup(t *testing.T, compose ComposeStack) {
t.Helper()
t.Cleanup(func() {
require.NoError(t, compose.Down(
Expand Down

0 comments on commit 9f7a5ca

Please sign in to comment.