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.
Introduce a
testcontainers_test
package to solve some of the docs i…
…mports As discussed in testcontainers#2180, the imported examples from tests for the docs from lack the package prefix before the imports, which leads to the example not being directly copy/paste-able. To solve the issue it was suggested to create a `testcontainers_test` package for the example tests and to convert everything. I did my best to convert all the tests in a way that makes sense, and I extracted any test that would import very internal things that we should not export. Some of the tests had to be slightly rewritten (the lifecycle tests in particular), but they should stay pretty much the same. Test by running all the root unit tests, they should all work as expected. The examples in the docs should all have the packages as prefixes now.
- Loading branch information
Showing
25 changed files
with
912 additions
and
815 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
Oops, something went wrong.