| 1 |
// Copyright The OpenTelemetry Authors |
| 2 |
// SPDX-License-Identifier: Apache-2.0 |
| 3 |
|
| 4 |
package testcomponents |
| 5 |
|
| 6 |
import ( |
| 7 |
"context" |
| 8 |
"testing" |
| 9 |
|
| 10 |
"github.com/stretchr/testify/assert" |
| 11 |
"github.com/stretchr/testify/require" |
| 12 |
|
| 13 |
"go.opentelemetry.io/collector/component/componenttest" |
| 14 |
) |
| 15 |
|
| 16 |
func TestExampleConnector(t *testing.T) { |
| 17 |
conn := &ExampleConnector{} |
| 18 |
host := componenttest.NewNopHost() |
| 19 |
assert.False(t, conn.Started()) |
| 20 |
require.NoError(t, conn.Start(context.Background(), host)) |
| 21 |
assert.True(t, conn.Started()) |
| 22 |
|
| 23 |
assert.False(t, conn.Stopped()) |
| 24 |
require.NoError(t, conn.Shutdown(context.Background())) |
| 25 |
assert.True(t, conn.Stopped()) |
| 26 |
} |