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.
Merge branch 'main' into Add-InfluxDB-Module
* main: chore(deps): Bumping ChromaGo client version (testcontainers#2402) chore(deps): bump github.com/docker/docker from 25.0.3+incompatible to 25.0.5+incompatible (testcontainers#2444) feat: support passing io.Reader as ContainerFile (testcontainers#2401)
- Loading branch information
Showing
90 changed files
with
369 additions
and
202 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,73 @@ | ||
// 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 ( | ||
"errors" | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
) | ||
|
||
func TestContainerFileValidation(t *testing.T) { | ||
type ContainerFileValidationTestCase struct { | ||
Name string | ||
ExpectedError error | ||
File ContainerFile | ||
} | ||
|
||
f, err := os.Open(filepath.Join(".", "testdata", "hello.sh")) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
testTable := []ContainerFileValidationTestCase{ | ||
{ | ||
Name: "valid container file: has hostfilepath", | ||
File: ContainerFile{ | ||
HostFilePath: "/path/to/host", | ||
ContainerFilePath: "/path/to/container", | ||
}, | ||
}, | ||
{ | ||
Name: "valid container file: has reader", | ||
File: ContainerFile{ | ||
Reader: f, | ||
ContainerFilePath: "/path/to/container", | ||
}, | ||
}, | ||
{ | ||
Name: "invalid container file", | ||
ExpectedError: errors.New("either HostFilePath or Reader must be specified"), | ||
File: ContainerFile{ | ||
HostFilePath: "", | ||
Reader: nil, | ||
ContainerFilePath: "/path/to/container", | ||
}, | ||
}, | ||
{ | ||
Name: "invalid container file", | ||
ExpectedError: errors.New("ContainerFilePath must be specified"), | ||
File: ContainerFile{ | ||
HostFilePath: "/path/to/host", | ||
ContainerFilePath: "", | ||
}, | ||
}, | ||
} | ||
|
||
for _, testCase := range testTable { | ||
t.Run(testCase.Name, func(t *testing.T) { | ||
err := testCase.File.validate() | ||
switch { | ||
case err == nil && testCase.ExpectedError == nil: | ||
return | ||
case err == nil && testCase.ExpectedError != nil: | ||
t.Errorf("did not receive expected error: %s", testCase.ExpectedError.Error()) | ||
case err != nil && testCase.ExpectedError == nil: | ||
t.Errorf("received unexpected error: %s", err.Error()) | ||
case err.Error() != testCase.ExpectedError.Error(): | ||
t.Errorf("errors mismatch: %s != %s", err.Error(), testCase.ExpectedError.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
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
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
Oops, something went wrong.