forked from testcontainers/testcontainers-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move the container and config tests into a test package
This work has been extracted from testcontainers#2202 and is related to testcontainers#2180. See the original PR for the full context and reasoning.
- Loading branch information
Showing
4 changed files
with
110 additions
and
63 deletions.
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
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,34 @@ | ||
// This test is testing very internal logic that should not be exported away from this package. We'll | ||
// leave it in the main testcontainers package. Do not use for user facing examples. | ||
package testcontainers | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestParseDockerIgnore(t *testing.T) { | ||
testCases := []struct { | ||
filePath string | ||
expectedErr error | ||
expectedExcluded []string | ||
}{ | ||
{ | ||
filePath: "./testdata/dockerignore", | ||
expectedErr: nil, | ||
expectedExcluded: []string{"vendor", "foo", "bar"}, | ||
}, | ||
{ | ||
filePath: "./testdata", | ||
expectedErr: nil, | ||
expectedExcluded: []string(nil), | ||
}, | ||
} | ||
|
||
for _, testCase := range testCases { | ||
excluded, err := parseDockerIgnore(testCase.filePath) | ||
assert.Equal(t, testCase.expectedErr, err) | ||
assert.Equal(t, testCase.expectedExcluded, excluded) | ||
} | ||
} |
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,36 @@ | ||
package testcontainers_test | ||
|
||
import ( | ||
"context" | ||
"os" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/testcontainers/testcontainers-go" | ||
) | ||
|
||
const ( | ||
nginxAlpineImage = "docker.io/nginx:alpine" | ||
nginxDefaultPort = "80/tcp" | ||
) | ||
|
||
var providerType = testcontainers.ProviderDocker | ||
|
||
func init() { | ||
if strings.Contains(os.Getenv("DOCKER_HOST"), "podman.sock") { | ||
providerType = testcontainers.ProviderPodman | ||
} | ||
} | ||
|
||
func terminateContainerOnEnd(tb testing.TB, ctx context.Context, ctr testcontainers.Container) { | ||
tb.Helper() | ||
if ctr == nil { | ||
return | ||
} | ||
tb.Cleanup(func() { | ||
tb.Log("terminating container") | ||
require.NoError(tb, ctr.Terminate(ctx)) | ||
}) | ||
} |