syft/internal/cache/cache_test.go
Keith Zantow af3aaa0397
fix: make caching options more explicit (#2966)
Signed-off-by: Keith Zantow <kzantow@gmail.com>
2024-06-14 18:45:48 +00:00

32 lines
626 B
Go

package cache
import (
"testing"
"time"
"github.com/stretchr/testify/require"
)
func Test_SetManager(t *testing.T) {
original := GetManager()
defer SetManager(original)
SetManager(nil)
require.NotNil(t, GetManager())
require.IsType(t, &bypassedCache{}, GetManager())
SetManager(NewInMemory(0))
require.NotNil(t, GetManager())
require.IsType(t, &bypassedCache{}, GetManager())
SetManager(NewInMemory(1 * time.Hour))
require.NotNil(t, GetManager())
require.IsType(t, &filesystemCache{}, GetManager())
SetManager(nil)
require.NotNil(t, GetManager())
require.IsType(t, &bypassedCache{}, GetManager())
}