yr/pkg/cache/cache_test.go
Tim Hårek Andreassen 019ec38fc1
feat: Add initial caching
References: https://todo.sr.ht/~timharek/yr/1
Signed-off-by: Tim Hårek Andreassen <tim@harek.no>
2024-10-04 21:53:00 +02:00

27 lines
508 B
Go

package cache
import (
"os"
"testing"
"github.com/stretchr/testify/assert"
)
type testType struct {
Prop1 string `json:"prop1"`
Prop2 string `json:"prop2"`
}
func TestCache(t *testing.T) {
assert := assert.New(t)
c := New[testType]("")
assert.Equal(os.TempDir(), c.Path)
err := c.Add("something", &testType{Prop1: "test1", Prop2: "test2"})
assert.NoError(err)
result, err := c.Get("something")
assert.NoError(err)
assert.Equal("test1", result.Prop1)
assert.Equal("test2", result.Prop2)
}