Skip to content

Commit

Permalink
update test setup
Browse files Browse the repository at this point in the history
  • Loading branch information
rarguelloF committed Aug 30, 2024
1 parent d61667b commit 2d5a31d
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 24 deletions.
4 changes: 1 addition & 3 deletions _integration-tests/tests/go-redis.v7/go-redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ func (tc *TestCase) Setup(t *testing.T) {
),
),
)
if err != nil {
t.Skipf("Failed to start redis test container: %v\n", err)
}
utils.AssertTestContainersError(t, err)

redisURI, err := tc.server.ConnectionString(ctx)
if err != nil {
Expand Down
4 changes: 1 addition & 3 deletions _integration-tests/tests/go-redis.v8/go-redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ func (tc *TestCase) Setup(t *testing.T) {
),
),
)
if err != nil {
t.Skipf("Failed to start redis test container: %v\n", err)
}
utils.AssertTestContainersError(t, err)

redisURI, err := tc.server.ConnectionString(ctx)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions _integration-tests/tests/ibm_sarama/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2023-present Datadog, Inc.

//go:build integration

package ibm_sarama

import (
Expand Down Expand Up @@ -46,9 +48,7 @@ func (tc *TestCase) Setup(t *testing.T) {
testcontainers.WithLogger(testcontainers.TestLogger(t)),
utils.WithTestLogConsumer(t),
)
if err != nil {
t.Skipf("Failed to start kafka test container: %v\n", err)
}
utils.AssertTestContainersError(t, err)

addr, err := tc.server.KafkaSeedBroker(ctx)
require.NoError(t, err, "failed to get seed broker address")
Expand Down
4 changes: 1 addition & 3 deletions _integration-tests/tests/mongo/mongo.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ func (tc *TestCase) Setup(t *testing.T) {
testcontainers.WithLogger(testcontainers.TestLogger(t)),
utils.WithTestLogConsumer(t),
)
if err != nil {
t.Skipf("Failed to start mongo test container: %v\n", err)
}
utils.AssertTestContainersError(t, err)

mongoURI, err := tc.server.ConnectionString(ctx)
if err != nil {
Expand Down
5 changes: 2 additions & 3 deletions _integration-tests/tests/redigo/redigo.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ func (tc *TestCase) Setup(t *testing.T) {
),
),
)
if err != nil {
t.Skipf("Failed to start redis test container: %v\n", err)
}
utils.AssertTestContainersError(t, err)

redisURI, err := tc.server.ConnectionString(ctx)
if err != nil {
log.Fatalf("Failed to obtain connection string: %v\n", err)
Expand Down
6 changes: 3 additions & 3 deletions _integration-tests/tests/shopify_sarama/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2023-present Datadog, Inc.

//go:build integration

package shopify_sarama

import (
Expand Down Expand Up @@ -46,9 +48,7 @@ func (tc *TestCase) Setup(t *testing.T) {
testcontainers.WithLogger(testcontainers.TestLogger(t)),
utils.WithTestLogConsumer(t),
)
if err != nil {
t.Skipf("Failed to start kafka test container: %v\n", err)
}
utils.AssertTestContainersError(t, err)

addr, err := tc.server.KafkaSeedBroker(ctx)
require.NoError(t, err, "failed to get seed broker address")
Expand Down
4 changes: 1 addition & 3 deletions _integration-tests/tests/vault/vault.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ func (tc *TestCase) Setup(t *testing.T) {
utils.WithTestLogConsumer(t),
testvault.WithToken("root"),
)
if err != nil {
t.Skipf("Failed to start vault test container: %v\n", err)
}
utils.AssertTestContainersError(t, err)

addr, err := tc.server.HttpHostAddress(ctx)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions _integration-tests/utils/testcontainers.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ func StartDynamoDBTestContainer(t *testing.T) (c testcontainers.Container, host
Image: "amazon/dynamodb-local:latest",
ExposedPorts: []string{exposedPort},
WaitingFor: wait.ForHTTP("").WithStatusCodeMatcher(func(int) bool { return true }),

Check warning on line 28 in _integration-tests/utils/testcontainers.go

View check run for this annotation

Codecov / codecov/patch

_integration-tests/utils/testcontainers.go#L22-L28

Added lines #L22 - L28 were not covered by tests
Name: "dynamodb-local",
WorkingDir: "/home/dynamodblocal",
Cmd: []string{
"-jar", "DynamoDBLocal.jar",
Expand All @@ -45,7 +44,7 @@ func StartDynamoDBTestContainer(t *testing.T) (c testcontainers.Container, host
server, err := testcontainers.GenericContainer(ctx, req)
AssertTestContainersError(t, err)

Check warning on line 45 in _integration-tests/utils/testcontainers.go

View check run for this annotation

Codecov / codecov/patch

_integration-tests/utils/testcontainers.go#L43-L45

Added lines #L43 - L45 were not covered by tests

mappedPort, err := server.MappedPort(ctx, nat.Port(port))
mappedPort, err := server.MappedPort(ctx, nat.Port(exposedPort))
require.NoError(t, err)

Check warning on line 48 in _integration-tests/utils/testcontainers.go

View check run for this annotation

Codecov / codecov/patch

_integration-tests/utils/testcontainers.go#L47-L48

Added lines #L47 - L48 were not covered by tests

host, err = server.Host(ctx)
Expand All @@ -61,7 +60,8 @@ func AssertTestContainersError(t *testing.T, err error) {
return

Check warning on line 60 in _integration-tests/utils/testcontainers.go

View check run for this annotation

Codecov / codecov/patch

_integration-tests/utils/testcontainers.go#L58-L60

Added lines #L58 - L60 were not covered by tests
}
if _, ok := os.LookupEnv("CI"); ok && runtime.GOOS != "linux" {
t.Skipf("skipping test since the current CI environment failed to start container: %v", err)
t.Skipf("failed to start container (CI does not support docker, skipping test): %v", err)
return

Check warning on line 64 in _integration-tests/utils/testcontainers.go

View check run for this annotation

Codecov / codecov/patch

_integration-tests/utils/testcontainers.go#L62-L64

Added lines #L62 - L64 were not covered by tests
}
require.NoError(t, err)

Check warning on line 66 in _integration-tests/utils/testcontainers.go

View check run for this annotation

Codecov / codecov/patch

_integration-tests/utils/testcontainers.go#L66

Added line #L66 was not covered by tests
}

0 comments on commit 2d5a31d

Please sign in to comment.