Skip to content

Commit

Permalink
test(compose): add several tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fiftin committed Jun 14, 2022
1 parent 3684807 commit 5eb916a
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions compose_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ func ExampleLocalDockerCompose_WithEnv() {

func enumDockerComposes(filePaths []string, identifier string, executor func(compose *LocalDockerCompose), t *testing.T) {
composes := []*LocalDockerCompose{
//NewLocalDockerCompose(filePaths, identifier, WithLogger(TestLogger(t))),
NewLocalDockerCompose(filePaths, identifier, WithLogger(TestLogger(t))),
NewContainerizedDockerCompose(filePaths, identifier, WithLogger(TestLogger(t))),
}

titles := []string{
//"NewLocalDockerCompose",
"NewLocalDockerCompose",
"NewContainerizedDockerCompose",
}

Expand Down Expand Up @@ -130,8 +130,8 @@ func TestDockerComposeStrategyForInvalidService(t *testing.T) {

identifier := strings.ToLower(uuid.New().String())

//compose := NewLocalDockerCompose([]string{path}, identifier, WithLogger(TestLogger(t)))
enumDockerComposes([]string{path}, identifier, func(compose *LocalDockerCompose) {
//compose := NewLocalDockerCompose([]string{path}, identifier, WithLogger(TestLogger(t)))
destroyFn := func() {
err := compose.Down()
checkIfError(t, err)
Expand All @@ -155,23 +155,25 @@ func TestDockerComposeWithWaitLogStrategy(t *testing.T) {

identifier := strings.ToLower(uuid.New().String())

compose := NewLocalDockerCompose([]string{path}, identifier, WithLogger(TestLogger(t)))
destroyFn := func() {
err := compose.Down()
checkIfError(t, err)
}
defer destroyFn()
//compose := NewLocalDockerCompose([]string{path}, identifier, WithLogger(TestLogger(t)))
enumDockerComposes([]string{path}, identifier, func(compose *LocalDockerCompose) {
destroyFn := func() {
err := compose.Down()
checkIfError(t, err)
}
defer destroyFn()

err := compose.
WithCommand([]string{"up", "-d"}).
// Appending with _1 as given in the Java Test-Containers Example
WithExposedService("mysql_1", 13306, wait.NewLogStrategy("started").WithStartupTimeout(10*time.Second).WithOccurrence(1)).
Invoke()
checkIfError(t, err)
err := compose.
WithCommand([]string{"up", "-d"}).
// Appending with _1 as given in the Java Test-Containers Example
WithExposedService("mysql_1", 13306, wait.NewLogStrategy("started").WithStartupTimeout(10*time.Second).WithOccurrence(1)).
Invoke()
checkIfError(t, err)

assert.Equal(t, 2, len(compose.Services))
assert.Contains(t, compose.Services, "nginx")
assert.Contains(t, compose.Services, "mysql")
assert.Equal(t, 2, len(compose.Services))
assert.Contains(t, compose.Services, "nginx")
assert.Contains(t, compose.Services, "mysql")
}, t)
}

func TestDockerComposeWithWaitForService(t *testing.T) {
Expand Down

0 comments on commit 5eb916a

Please sign in to comment.