Debian Codegraph @

processor/batchprocessor/factory_test.go

raw
1 // Copyright The OpenTelemetry Authors
2 // SPDX-License-Identifier: Apache-2.0
3
4 package batchprocessor
5
6 import (
7 "context"
8 "testing"
9
10 "github.com/stretchr/testify/assert"
11
12 "go.opentelemetry.io/collector/component/componenttest"
13 "go.opentelemetry.io/collector/processor/processortest"
14 )
15
16 func TestCreateDefaultConfig(t *testing.T) {
17 factory := NewFactory()
18
19 cfg := factory.CreateDefaultConfig()
20 assert.NotNil(t, cfg, "failed to create default config")
21 assert.NoError(t, componenttest.CheckConfigStruct(cfg))
22 }
23
24 func TestCreateProcessor(t *testing.T) {
25 factory := NewFactory()
26
27 cfg := factory.CreateDefaultConfig()
28 creationSet := processortest.NewNopSettings(factory.Type())
29 tp, err := factory.CreateTraces(context.Background(), creationSet, cfg, nil)
30 assert.NotNil(t, tp)
31 assert.NoError(t, err, "cannot create trace processor")
32 assert.NoError(t, tp.Shutdown(context.Background()))
33
34 mp, err := factory.CreateMetrics(context.Background(), creationSet, cfg, nil)
35 assert.NotNil(t, mp)
36 assert.NoError(t, err, "cannot create metric processor")
37 assert.NoError(t, mp.Shutdown(context.Background()))
38
39 lp, err := factory.CreateLogs(context.Background(), creationSet, cfg, nil)
40 assert.NotNil(t, lp)
41 assert.NoError(t, err, "cannot create logs processor")
42 assert.NoError(t, lp.Shutdown(context.Background()))
43 }