-
-
Notifications
You must be signed in to change notification settings - Fork 511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move the container and config tests into a test package #2242
Merged
mdelapenya
merged 6 commits into
testcontainers:main
from
Minivera:gui/move-container-test-to-test-package
Mar 12, 2024
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2dc8276
Move the container and config tests into a test package
Minivera cde105f
Merge remote-tracking branch 'origin/main' into gui/move-container-te…
Minivera 150f331
Rename the utils file
Minivera 21d5a8b
Remove some unused code
Minivera d1e51a6
Merge remote-tracking branch 'origin/main' into gui/move-container-te…
Minivera 28dd258
Merge branch 'main' into gui/move-container-test-to-test-package
Minivera File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)) | ||
}) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason for this file to be here? I cannot see usages of the functions on it in the current changeset
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are utilities that are currently in the
docker_test
file and are used in the modified tests. Since thedocker_test
file isn't moved yet, I've temporarily created this utils file, it should go away when every thing is migrated 🙂There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
terminateContainerOnEnd
is used in most of the test files that were moved into their own packages, so we do need to move them to a into thetestcontainers_test
package so they're accessible. They don't show up in the diff because I didn't touch those lines, I only moved the tests.