-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfactory_test.go
42 lines (35 loc) · 1.03 KB
/
factory_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package scwaudittrail
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/component/componenttest"
"go.opentelemetry.io/collector/consumer/consumertest"
"go.opentelemetry.io/collector/receiver/receivertest"
gomock "go.uber.org/mock/gomock"
)
func TestCreateReceiver(t *testing.T) {
rCfg := createDefaultConfig().(*Config)
// Fails with bad SCW Config.
_, err := createLogsReceiver(
context.Background(), receivertest.NewNopSettings(),
rCfg, consumertest.NewNop(),
)
assert.Error(t, err)
// Override for test.
rCfg.makeClient = func(_ *Config) (Client, error) {
ctrl := gomock.NewController(t)
client := NewMockClient(ctrl)
return client, nil
}
r, err := createLogsReceiver(
context.Background(),
receivertest.NewNopSettings(),
rCfg, consumertest.NewNop(),
)
require.NoError(t, err)
err = r.Start(context.Background(), componenttest.NewNopHost())
assert.NoError(t, err)
require.NoError(t, r.Shutdown(context.Background()))
}