mirror of
https://github.com/tgdrive/teldrive.git
synced 2025-01-09 16:49:51 +08:00
27 lines
463 B
Go
27 lines
463 B
Go
package cache
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/tgdrive/teldrive/pkg/schemas"
|
|
)
|
|
|
|
func TestCache(t *testing.T) {
|
|
|
|
var value = schemas.FileIn{
|
|
Name: "file.jpeg",
|
|
Type: "file",
|
|
}
|
|
var result schemas.FileIn
|
|
|
|
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)
|
|
}
|