forked from open-telemetry/opentelemetry-collector-contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generated_component_test.go
49 lines (41 loc) · 1.66 KB
/
generated_component_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
43
44
45
46
47
48
49
// Code generated by mdatagen. DO NOT EDIT.
package filestorage
import (
"context"
"testing"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/component/componenttest"
"go.opentelemetry.io/collector/confmap/confmaptest"
"go.opentelemetry.io/collector/extension/extensiontest"
)
func TestComponentFactoryType(t *testing.T) {
require.Equal(t, "file_storage", NewFactory().Type().String())
}
func TestComponentConfigStruct(t *testing.T) {
require.NoError(t, componenttest.CheckConfigStruct(NewFactory().CreateDefaultConfig()))
}
func TestComponentLifecycle(t *testing.T) {
factory := NewFactory()
cm, err := confmaptest.LoadConf("metadata.yaml")
require.NoError(t, err)
cfg := factory.CreateDefaultConfig()
sub, err := cm.Sub("tests::config")
require.NoError(t, err)
require.NoError(t, sub.Unmarshal(&cfg))
t.Run("shutdown", func(t *testing.T) {
e, err := factory.CreateExtension(context.Background(), extensiontest.NewNopCreateSettings(), cfg)
require.NoError(t, err)
err = e.Shutdown(context.Background())
require.NoError(t, err)
})
t.Run("lifecycle", func(t *testing.T) {
firstExt, err := factory.CreateExtension(context.Background(), extensiontest.NewNopCreateSettings(), cfg)
require.NoError(t, err)
require.NoError(t, firstExt.Start(context.Background(), componenttest.NewNopHost()))
require.NoError(t, firstExt.Shutdown(context.Background()))
secondExt, err := factory.CreateExtension(context.Background(), extensiontest.NewNopCreateSettings(), cfg)
require.NoError(t, err)
require.NoError(t, secondExt.Start(context.Background(), componenttest.NewNopHost()))
require.NoError(t, secondExt.Shutdown(context.Background()))
})
}