| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
package zpagesextension |
| 5 |
|
| 6 |
import ( |
| 7 |
"path/filepath" |
| 8 |
"testing" |
| 9 |
|
| 10 |
"github.com/stretchr/testify/assert" |
| 11 |
"github.com/stretchr/testify/require" |
| 12 |
|
| 13 |
"go.opentelemetry.io/collector/config/confighttp" |
| 14 |
"go.opentelemetry.io/collector/confmap" |
| 15 |
"go.opentelemetry.io/collector/confmap/confmaptest" |
| 16 |
) |
| 17 |
|
| 18 |
func TestUnmarshalDefaultConfig(t *testing.T) { |
| 19 |
factory := NewFactory() |
| 20 |
cfg := factory.CreateDefaultConfig() |
| 21 |
require.NoError(t, confmap.New().Unmarshal(&cfg)) |
| 22 |
assert.Equal(t, factory.CreateDefaultConfig(), cfg) |
| 23 |
} |
| 24 |
|
| 25 |
func TestInvalidConfig(t *testing.T) { |
| 26 |
assert.Error(t, (&Config{}).Validate()) |
| 27 |
} |
| 28 |
|
| 29 |
func TestUnmarshalConfig(t *testing.T) { |
| 30 |
cm, err := confmaptest.LoadConf(filepath.Join("testdata", "config.yaml")) |
| 31 |
require.NoError(t, err) |
| 32 |
factory := NewFactory() |
| 33 |
cfg := factory.CreateDefaultConfig() |
| 34 |
require.NoError(t, cm.Unmarshal(&cfg)) |
| 35 |
assert.Equal(t, |
| 36 |
&Config{ |
| 37 |
ServerConfig: confighttp.ServerConfig{ |
| 38 |
Endpoint: "localhost:56888", |
| 39 |
}, |
| 40 |
}, cfg) |
| 41 |
} |