signoz/pkg/config/config_test.go
Vikrant Gupta 4967696da8
feat: added new cache package for query service (#6733)
* feat: added new cache package for query service

* feat: handle type checking for inmemory

* feat: some copy corrections

* feat: added inmemory test cases

* chore: some renaming

* feat: added redis handling

* chore: add redis tests

* feat(cache): refactor the code

* feat(cache): refactor the code

* feat(cache): added defaults for redis config

* feat(cache): update makefile to run all tetss

* feat(cache): update tests and docs

* feat(cache): update tests and docs

* feat(cache): handle signoz web flag

* feat(cache): handle signoz web flag

* feat(cache): handle signoz web flag
2025-01-04 01:28:54 +05:30

55 lines
1.2 KiB
Go

package config
import (
"context"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/confmap"
"go.signoz.io/signoz/pkg/cache"
"go.signoz.io/signoz/pkg/confmap/provider/signozenvprovider"
"go.signoz.io/signoz/pkg/web"
)
func TestNewWithSignozEnvProvider(t *testing.T) {
t.Setenv("SIGNOZ__WEB__PREFIX", "/web")
t.Setenv("SIGNOZ__WEB__DIRECTORY", "/build")
t.Setenv("SIGNOZ__CACHE__PROVIDER", "redis")
t.Setenv("SIGNOZ__CACHE__REDIS__HOST", "127.0.0.1")
config, err := New(context.Background(), ProviderSettings{
ResolverSettings: confmap.ResolverSettings{
URIs: []string{"signozenv:"},
ProviderFactories: []confmap.ProviderFactory{
signozenvprovider.NewFactory(),
},
},
})
require.NoError(t, err)
expected := &Config{
Web: web.Config{
Prefix: "/web",
Directory: "/build",
},
Cache: cache.Config{
Provider: "redis",
Memory: cache.Memory{
TTL: time.Duration(-1),
CleanupInterval: 1 * time.Minute,
},
Redis: cache.Redis{
Host: "127.0.0.1",
Port: 6379,
Password: "",
DB: 0,
},
},
}
assert.Equal(t, expected, config)
}