Skip to content

Commit

Permalink
(#25) Create defer functions the soonest
Browse files Browse the repository at this point in the history
  • Loading branch information
mdelapenya committed Apr 16, 2020
1 parent 3c26102 commit a07447a
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions compose_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ func TestLocalDockerCompose(t *testing.T) {
identifier := strings.ToLower(uuid.New().String())

compose := NewLocalDockerCompose([]string{path}, identifier)
destroyFn := func() {
err := compose.Down()
checkIfError(t, err)
}
defer destroyFn()

err := compose.
WithCommand([]string{"up", "-d"}).
Expand All @@ -26,12 +31,6 @@ func TestLocalDockerCompose(t *testing.T) {
}
absent := map[string]string{}
assertContainerEnvironmentVariables(t, compose.Identifier+"_nginx_1", present, absent)

destroyFn := func() {
err := compose.Down()
checkIfError(t, err)
}
defer destroyFn()
}

func TestLocalDockerComposeComplex(t *testing.T) {
Expand All @@ -40,17 +39,16 @@ func TestLocalDockerComposeComplex(t *testing.T) {
identifier := strings.ToLower(uuid.New().String())

compose := NewLocalDockerCompose([]string{path}, identifier)

err := compose.
WithCommand([]string{"up", "-d"}).
Invoke()
checkIfError(t, err)

destroyFn := func() {
err := compose.Down()
checkIfError(t, err)
}
defer destroyFn()

err := compose.
WithCommand([]string{"up", "-d"}).
Invoke()
checkIfError(t, err)
}

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

0 comments on commit a07447a

Please sign in to comment.