mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-01 09:31:58 +08:00

* feat: get collectorsimulator started and add inmemoryreceiver * feat: add collectorsimulator/inmemoryexporter * feat: add collectorsimulator.SimulateLogsProcessing * chore: clean up collector simulator code a little * chore: update go.sum entries for cors * chore: add collectorsimulator tests to make cmd * chore: move to latest dependency version for collectorsimulator * chore: revert to dependency versions matching signoz-otel-col * chore: cleanup: reorganize collectorsimulator logic * chore: some more cleanup * chore: some more cleanup * chore: some more cleanup * chore: redo go.mod
49 lines
1.1 KiB
Go
49 lines
1.1 KiB
Go
package inmemoryreceiver
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
"go.opentelemetry.io/collector/component"
|
|
"go.opentelemetry.io/collector/confmap"
|
|
)
|
|
|
|
func TestValidate(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
rawConf *confmap.Conf
|
|
errorExpected bool
|
|
}{
|
|
{
|
|
name: "with id",
|
|
rawConf: confmap.NewFromStringMap(map[string]interface{}{
|
|
"id": "test_receiver",
|
|
}),
|
|
errorExpected: false,
|
|
},
|
|
{
|
|
name: "empty id",
|
|
rawConf: confmap.NewFromStringMap(map[string]interface{}{
|
|
"id": "",
|
|
}),
|
|
errorExpected: true,
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
factory := NewFactory()
|
|
cfg := factory.CreateDefaultConfig()
|
|
err := component.UnmarshalConfig(tt.rawConf, cfg)
|
|
require.NoError(t, err, "could not UnmarshalConfig")
|
|
|
|
err = component.ValidateConfig(cfg)
|
|
if tt.errorExpected {
|
|
require.NotNilf(t, err, "Invalid config did not return validation error: %v", cfg)
|
|
} else {
|
|
require.NoErrorf(t, err, "Valid config returned validation error: %v", cfg)
|
|
}
|
|
})
|
|
}
|
|
}
|