dashboard_cache_test.go 636 B

12345678910111213141516171819202122232425262728
  1. package repository
  2. import (
  3. "testing"
  4. "github.com/Wei-Shaw/sub2api/internal/config"
  5. "github.com/stretchr/testify/require"
  6. )
  7. func TestNewDashboardCacheKeyPrefix(t *testing.T) {
  8. cache := NewDashboardCache(nil, &config.Config{
  9. Dashboard: config.DashboardCacheConfig{
  10. KeyPrefix: "prod",
  11. },
  12. })
  13. impl, ok := cache.(*dashboardCache)
  14. require.True(t, ok)
  15. require.Equal(t, "prod:", impl.keyPrefix)
  16. cache = NewDashboardCache(nil, &config.Config{
  17. Dashboard: config.DashboardCacheConfig{
  18. KeyPrefix: "staging:",
  19. },
  20. })
  21. impl, ok = cache.(*dashboardCache)
  22. require.True(t, ok)
  23. require.Equal(t, "staging:", impl.keyPrefix)
  24. }