019ec38fc1
References: https://todo.sr.ht/~timharek/yr/1 Signed-off-by: Tim Hårek Andreassen <tim@harek.no>
27 lines
508 B
Go
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)
|
|
}
|