grafana/pkg/setting/setting_unified_storage_test.go
maicon 377079d8b3
UniStore: Add config to enable periodic DualWriter DataSyncer (#93555)
Signed-off-by: Maicon Costa <maiconscosta@gmail.com>
2024-09-24 22:03:15 +03:00

35 lines
883 B
Go

package setting
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestCfg_setUnifiedStorageConfig(t *testing.T) {
t.Run("read unified_storage configs", func(t *testing.T) {
cfg := NewCfg()
err := cfg.Load(CommandLineArgs{HomePath: "../../", Config: "../../conf/defaults.ini"})
assert.NoError(t, err)
s, err := cfg.Raw.NewSection("unified_storage.playlists.playlist.grafana.app")
assert.NoError(t, err)
_, err = s.NewKey("dualWriterMode", "2")
assert.NoError(t, err)
_, err = s.NewKey("dualWriterPeriodicDataSyncJobEnabled", "true")
assert.NoError(t, err)
cfg.setUnifiedStorageConfig()
value, exists := cfg.UnifiedStorage["playlists.playlist.grafana.app"]
assert.Equal(t, exists, true)
assert.Equal(t, value, UnifiedStorageConfig{
DualWriterMode: 2,
DualWriterPeriodicDataSyncJobEnabled: true,
})
})
}