mirror of
https://github.com/hanzoai/otel-collector.git
synced 2026-11-02 13:34:59 +00:00
- imports: ClickHouse/ch-go, clickhouse-go/v2, srikanthccv/ClickHouse-go-mock
-> github.com/hanzo-ds/{native,go,mock} (require, clean semver, NO replace)
- identifiers/aliases/type-names/config-keys/type-IDs: clickhouse -> datastore
(receiver dir clickhousesystemtablesreceiver -> datastoresystemtablesreceiver)
- DSN scheme clickhouse:// -> datastore:// (driver treats non-http/https as Native)
- removed the go.opencensus.io version-pin replace (require-pinned instead)
- kept: real external refs (github.com/ClickHouse, clickhouse.com docs) and the
hanzo-ds/mock test API (NewClickHouseNative) pending the mock's own rename
Full ./... build passes. 0 replace directives, 0 signoz.
56 lines
1.2 KiB
Go
56 lines
1.2 KiB
Go
package datastoresystemtablesreceiver
|
|
|
|
import (
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
"go.opentelemetry.io/collector/confmap/confmaptest"
|
|
"go.opentelemetry.io/collector/confmap/xconfmap"
|
|
)
|
|
|
|
func TestLoadConfig(t *testing.T) {
|
|
require := require.New(t)
|
|
|
|
tests := []struct {
|
|
name string
|
|
testConfFileName string
|
|
expectedErr bool
|
|
}{
|
|
{
|
|
name: "valid",
|
|
testConfFileName: "config.yaml",
|
|
expectedErr: false,
|
|
}, {
|
|
name: "no dsn specified",
|
|
testConfFileName: "badConfigNoDsn.yaml",
|
|
expectedErr: true,
|
|
}, {
|
|
name: "no min scrape delay specified",
|
|
testConfFileName: "badConfigNoScrapeDelay.yaml",
|
|
expectedErr: true,
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
factory := NewFactory()
|
|
cfg := factory.CreateDefaultConfig()
|
|
|
|
cm, err := confmaptest.LoadConf(filepath.Join("testdata", tt.testConfFileName))
|
|
require.Nil(err)
|
|
|
|
sub, err := cm.Sub("datastoresystemtablesreceiver")
|
|
require.Nil(err)
|
|
|
|
require.NoError(sub.Unmarshal(cfg))
|
|
|
|
if tt.expectedErr {
|
|
require.Error(xconfmap.Validate(cfg))
|
|
} else {
|
|
require.NoError(xconfmap.Validate(cfg))
|
|
|
|
}
|
|
}
|
|
|
|
}
|