Skip to content

Commit

Permalink
[chore] remove use of ReportFatalError in test
Browse files Browse the repository at this point in the history
  • Loading branch information
atoulme committed Mar 17, 2024
1 parent 794cd24 commit 3ff249d
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions extension/observer/dockerobserver/integration_test.go
Expand Up @@ -8,6 +8,7 @@ package dockerobserver
import (
"context"
"fmt"
"go.opentelemetry.io/collector/component/componenttest"
"sync"
"testing"
"time"
Expand All @@ -16,24 +17,11 @@ import (
"github.com/stretchr/testify/require"
"github.com/testcontainers/testcontainers-go"
"github.com/testcontainers/testcontainers-go/wait"
"go.opentelemetry.io/collector/component"
"go.uber.org/zap"

"github.com/open-telemetry/opentelemetry-collector-contrib/extension/observer"
)

type testHost struct {
component.Host
t *testing.T
}

// ReportFatalError causes the test to be run to fail.
func (h *testHost) ReportFatalError(err error) {
h.t.Fatalf("Receiver reported a fatal error: %v", err)
}

var _ component.Host = (*testHost)(nil)

func TestObserverEmitsEndpointsIntegration(t *testing.T) {
image := "docker.io/library/nginx"
tag := "1.17"
Expand Down Expand Up @@ -226,9 +214,7 @@ func startObserverWithConfig(t *testing.T, listener observer.Notify, c *Config)
obvs, ok := ext.(*dockerObserver)
require.True(t, ok)
require.NoError(t, err, "failed creating extension")
require.NoError(t, obvs.Start(ctx, &testHost{
t: t,
}))
require.NoError(t, obvs.Start(ctx, componenttest.NewNopHost()))

go obvs.ListAndWatch(listener)
return obvs
Expand Down

0 comments on commit 3ff249d

Please sign in to comment.