photoprism/internal/entity/album_cache_test.go
Michael Mayer d8e0364dbb Search: Ignore public album filter if "Private" feat is disabled #2570
This needs to be very well tested and discussed, as these changes can
lead to private photos being accidentally published. Thank you!

Signed-off-by: Michael Mayer <michael@photoprism.app>
2022-08-01 15:57:19 +02:00

54 lines
1.4 KiB
Go

package entity
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestFlushAlbumCache(t *testing.T) {
t.Run("Success", func(t *testing.T) {
FlushAlbumCache()
})
}
func TestCachedAlbumByUID(t *testing.T) {
t.Run("EmptyUID", func(t *testing.T) {
if _, err := CachedAlbumByUID(""); err == nil {
t.Fatal("error expected")
}
})
t.Run("InvalidUID", func(t *testing.T) {
if _, err := CachedAlbumByUID("fxgsdrgrg"); err == nil {
t.Fatal("error expected")
}
})
t.Run("at9lxuqxpogaaba7", func(t *testing.T) {
if result, err := CachedAlbumByUID("at9lxuqxpogaaba7"); err != nil {
t.Fatal(err)
} else {
assert.Equal(t, "at9lxuqxpogaaba7", result.AlbumUID)
assert.Equal(t, "christmas-2030", result.AlbumSlug)
}
if cached, err := CachedAlbumByUID("at9lxuqxpogaaba7"); err != nil {
t.Fatal(err)
} else {
assert.Equal(t, "at9lxuqxpogaaba7", cached.AlbumUID)
assert.Equal(t, "christmas-2030", cached.AlbumSlug)
}
})
t.Run("at1lxuqipotaab23", func(t *testing.T) {
if result, err := CachedAlbumByUID("at1lxuqipotaab23"); err != nil {
t.Fatal(err)
} else {
assert.Equal(t, "at1lxuqipotaab23", result.AlbumUID)
assert.Equal(t, "pest&dogs", result.AlbumSlug)
}
if cached, err := CachedAlbumByUID("at1lxuqipotaab23"); err != nil {
t.Fatal(err)
} else {
assert.Equal(t, "at1lxuqipotaab23", cached.AlbumUID)
assert.Equal(t, "pest&dogs", cached.AlbumSlug)
}
})
}