mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-07-29 11:41:58 +08:00

- Introduces `Config`, `ConfigFactory`, `ProviderFactory`, and `Service` interfaces in `config.go`, `provider.go`, and `service.go`. - Implements `NamedMap` for managing named factories in `named.go`. - Adds `ProviderSettings` and `ScopedProviderSettings` for managing provider settings in `setting.go`.
30 lines
562 B
Go
30 lines
562 B
Go
package factory
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
type c1 struct{}
|
|
|
|
func (c1) Validate() error {
|
|
return nil
|
|
}
|
|
|
|
func TestNewConfigFactory(t *testing.T) {
|
|
cf := NewConfigFactory(MustNewName("c1"), func() Config {
|
|
return c1{}
|
|
})
|
|
assert.Equal(t, MustNewName("c1"), cf.Name())
|
|
assert.IsType(t, c1{}, cf.New())
|
|
}
|
|
|
|
func TestNewConfigFactoryWithPointer(t *testing.T) {
|
|
cfp := NewConfigFactory(MustNewName("c1"), func() Config {
|
|
return &c1{}
|
|
})
|
|
assert.Equal(t, MustNewName("c1"), cfp.Name())
|
|
assert.IsType(t, &c1{}, cfp.New())
|
|
}
|