photoprism/internal/entity/album_cache_test.go
Michael Mayer 713593da4e Auth: Add CLI command to create access tokens for apps #782 #808 #3943
You can now run "photoprism auth add" to create new client access tokens
that allow external applications to use the built-in REST API.

Signed-off-by: Michael Mayer <michael@photoprism.app>
2024-01-05 16:31:07 +01:00

54 lines
1.4 KiB
Go

package entity
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestFlushAlbumCache(t *testing.T) {
t.Run("Ok", 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("as6sg6bxpogaaba7", func(t *testing.T) {
if result, err := CachedAlbumByUID("as6sg6bxpogaaba7"); err != nil {
t.Fatal(err)
} else {
assert.Equal(t, "as6sg6bxpogaaba7", result.AlbumUID)
assert.Equal(t, "christmas-2030", result.AlbumSlug)
}
if cached, err := CachedAlbumByUID("as6sg6bxpogaaba7"); err != nil {
t.Fatal(err)
} else {
assert.Equal(t, "as6sg6bxpogaaba7", cached.AlbumUID)
assert.Equal(t, "christmas-2030", cached.AlbumSlug)
}
})
t.Run("as6sg6bipotaab23", func(t *testing.T) {
if result, err := CachedAlbumByUID("as6sg6bipotaab23"); err != nil {
t.Fatal(err)
} else {
assert.Equal(t, "as6sg6bipotaab23", result.AlbumUID)
assert.Equal(t, "pest&dogs", result.AlbumSlug)
}
if cached, err := CachedAlbumByUID("as6sg6bipotaab23"); err != nil {
t.Fatal(err)
} else {
assert.Equal(t, "as6sg6bipotaab23", cached.AlbumUID)
assert.Equal(t, "pest&dogs", cached.AlbumSlug)
}
})
}