lib/cache: add PutErr to put a value with an error into the cache

This commit is contained in:
Nick Craig-Wood
2024-01-19 10:33:24 +00:00
parent 6ff1b6c505
commit e3f6f68885
2 changed files with 24 additions and 2 deletions

View File

@ -81,6 +81,22 @@ func TestGetError(t *testing.T) {
assert.Equal(t, 0, len(c.cache))
}
func TestPutErr(t *testing.T) {
c, create := setup(t)
assert.Equal(t, 0, len(c.cache))
c.PutErr("/alien", "slime", errSentinel)
assert.Equal(t, 1, len(c.cache))
fNew, err := c.Get("/alien", create)
require.Equal(t, errSentinel, err)
require.Equal(t, "slime", fNew)
assert.Equal(t, 1, len(c.cache))
}
func TestPut(t *testing.T) {
c, create := setup(t)