teldrive/internal/cache/cache_test.go

28 lines
463 B
Go
Raw Normal View History

package cache
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
2024-08-31 23:50:17 +08:00
"github.com/tgdrive/teldrive/pkg/schemas"
)
func TestCache(t *testing.T) {
var value = schemas.FileIn{
Name: "file.jpeg",
Type: "file",
}
var result schemas.FileIn
2024-07-26 23:50:26 +08:00
cache := NewMemoryCache(1 * 1024 * 1024)
err := cache.Set("key", value, 1*time.Second)
assert.NoError(t, err)
err = cache.Get("key", &result)
assert.NoError(t, err)
assert.Equal(t, result, value)
}