Skip to content

Commit

Permalink
chore: use require.(No)Error(t,err) instead of t.Fatal(err) (#2851)
Browse files Browse the repository at this point in the history
Signed-off-by: Matthieu MOREL <[email protected]>
  • Loading branch information
mmorel-35 authored Oct 28, 2024
1 parent 7ca3d8e commit b7511cd
Show file tree
Hide file tree
Showing 20 changed files with 150 additions and 405 deletions.
6 changes: 3 additions & 3 deletions container_file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"os"
"path/filepath"
"testing"

"github.com/stretchr/testify/require"
)

func TestContainerFileValidation(t *testing.T) {
Expand All @@ -17,9 +19,7 @@ func TestContainerFileValidation(t *testing.T) {
}

f, err := os.Open(filepath.Join(".", "testdata", "hello.sh"))
if err != nil {
t.Fatal(err)
}
require.NoError(t, err)

testTable := []ContainerFileValidationTestCase{
{
Expand Down
36 changes: 9 additions & 27 deletions docker_files_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,10 @@ func TestCopyFileToContainer(t *testing.T) {

// copyFileOnCreate {
absPath, err := filepath.Abs(filepath.Join(".", "testdata", "hello.sh"))
if err != nil {
t.Fatal(err)
}
require.NoError(t, err)

r, err := os.Open(absPath)
if err != nil {
t.Fatal(err)
}
require.NoError(t, err)

ctr, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{
ContainerRequest: testcontainers.ContainerRequest{
Expand Down Expand Up @@ -58,13 +54,9 @@ func TestCopyFileToRunningContainer(t *testing.T) {
// Not using the assertations here to avoid leaking the library into the example
// copyFileAfterCreate {
waitForPath, err := filepath.Abs(filepath.Join(".", "testdata", "waitForHello.sh"))
if err != nil {
t.Fatal(err)
}
require.NoError(t, err)
helloPath, err := filepath.Abs(filepath.Join(".", "testdata", "hello.sh"))
if err != nil {
t.Fatal(err)
}
require.NoError(t, err)

ctr, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{
ContainerRequest: testcontainers.ContainerRequest{
Expand Down Expand Up @@ -100,9 +92,7 @@ func TestCopyDirectoryToContainer(t *testing.T) {
// Not using the assertations here to avoid leaking the library into the example
// copyDirectoryToContainer {
dataDirectory, err := filepath.Abs(filepath.Join(".", "testdata"))
if err != nil {
t.Fatal(err)
}
require.NoError(t, err)

ctr, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{
ContainerRequest: testcontainers.ContainerRequest{
Expand Down Expand Up @@ -133,13 +123,9 @@ func TestCopyDirectoryToRunningContainerAsFile(t *testing.T) {

// copyDirectoryToRunningContainerAsFile {
dataDirectory, err := filepath.Abs(filepath.Join(".", "testdata"))
if err != nil {
t.Fatal(err)
}
require.NoError(t, err)
waitForPath, err := filepath.Abs(filepath.Join(dataDirectory, "waitForHello.sh"))
if err != nil {
t.Fatal(err)
}
require.NoError(t, err)

ctr, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{
ContainerRequest: testcontainers.ContainerRequest{
Expand Down Expand Up @@ -175,13 +161,9 @@ func TestCopyDirectoryToRunningContainerAsDir(t *testing.T) {
// Not using the assertations here to avoid leaking the library into the example
// copyDirectoryToRunningContainerAsDir {
waitForPath, err := filepath.Abs(filepath.Join(".", "testdata", "waitForHello.sh"))
if err != nil {
t.Fatal(err)
}
require.NoError(t, err)
dataDirectory, err := filepath.Abs(filepath.Join(".", "testdata"))
if err != nil {
t.Fatal(err)
}
require.NoError(t, err)

ctr, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{
ContainerRequest: testcontainers.ContainerRequest{
Expand Down
Loading

0 comments on commit b7511cd

Please sign in to comment.