-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'pull-request-635' of https://github.com/rguthriemsft/te…
…rratest into pull-request-635
- Loading branch information
Showing
7 changed files
with
75 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# website::tag::1:: Build a simple Docker image that contains a text file with the contents "Hello, World!" | ||
FROM ubuntu:20.04 | ||
COPY ./bash_script.sh /usr/local/bin/bash_script.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
echo "stdout: message" | ||
>&2 echo -e "stderr: error" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
version: '2.0' | ||
services: | ||
bash_script: | ||
build: | ||
context: . | ||
entrypoint: bash_script.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/gruntwork-io/terratest/modules/docker" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestDockerComposeStdoutExample(t *testing.T) { | ||
t.Parallel() | ||
dockerComposeFile := "../examples/docker-compose-stdout-example/docker-compose.yml" | ||
|
||
// Run the build step first so that the build output doesn't go to stdout during the compose step. | ||
docker.RunDockerCompose( | ||
t, | ||
&docker.Options{}, | ||
"-f", | ||
dockerComposeFile, | ||
"build", | ||
) | ||
|
||
// Run the Docker image, read the stdout from it, and make sure it contains the expected output. | ||
// The script must be run using `run bash_script` rather than `up`, so that the echo output from the script | ||
// is the only thing that outputs to stdout. | ||
output := docker.RunDockerComposeAndGetStdOut( | ||
t, | ||
&docker.Options{}, | ||
"-f", | ||
dockerComposeFile, | ||
"run", | ||
"bash_script", | ||
) | ||
|
||
assert.Contains(t, output, "stdout: message") | ||
assert.NotContains(t, output, "stderr: error") | ||
} |