mirror of
https://github.com/tgdrive/teldrive.git
synced 2025-01-10 01:02:01 +08:00
28 lines
489 B
Go
28 lines
489 B
Go
package cache
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/divyam234/teldrive/pkg/schemas"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestCache(t *testing.T) {
|
|
ctx := context.Background()
|
|
cache := FromContext(ctx)
|
|
|
|
var value = schemas.FileIn{
|
|
Name: "file.jpeg",
|
|
Type: "file",
|
|
}
|
|
var result schemas.FileIn
|
|
|
|
err := cache.Set("key", value, 1*time.Minute)
|
|
assert.NoError(t, err)
|
|
|
|
err = cache.Get("key", &result)
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, result, value)
|
|
}
|