2022-08-01 15:57:19 +02:00
|
|
|
package entity
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestFlushAlbumCache(t *testing.T) {
|
2022-10-13 22:11:02 +02:00
|
|
|
t.Run("Ok", func(t *testing.T) {
|
2022-08-01 15:57:19 +02:00
|
|
|
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")
|
|
|
|
}
|
|
|
|
})
|
2024-01-05 16:31:07 +01:00
|
|
|
t.Run("as6sg6bxpogaaba7", func(t *testing.T) {
|
|
|
|
if result, err := CachedAlbumByUID("as6sg6bxpogaaba7"); err != nil {
|
2022-08-01 15:57:19 +02:00
|
|
|
t.Fatal(err)
|
|
|
|
} else {
|
2024-01-05 16:31:07 +01:00
|
|
|
assert.Equal(t, "as6sg6bxpogaaba7", result.AlbumUID)
|
2022-08-01 15:57:19 +02:00
|
|
|
assert.Equal(t, "christmas-2030", result.AlbumSlug)
|
|
|
|
}
|
2024-01-05 16:31:07 +01:00
|
|
|
if cached, err := CachedAlbumByUID("as6sg6bxpogaaba7"); err != nil {
|
2022-08-01 15:57:19 +02:00
|
|
|
t.Fatal(err)
|
|
|
|
} else {
|
2024-01-05 16:31:07 +01:00
|
|
|
assert.Equal(t, "as6sg6bxpogaaba7", cached.AlbumUID)
|
2022-08-01 15:57:19 +02:00
|
|
|
assert.Equal(t, "christmas-2030", cached.AlbumSlug)
|
|
|
|
}
|
|
|
|
})
|
2024-01-05 16:31:07 +01:00
|
|
|
t.Run("as6sg6bipotaab23", func(t *testing.T) {
|
|
|
|
if result, err := CachedAlbumByUID("as6sg6bipotaab23"); err != nil {
|
2022-08-01 15:57:19 +02:00
|
|
|
t.Fatal(err)
|
|
|
|
} else {
|
2024-01-05 16:31:07 +01:00
|
|
|
assert.Equal(t, "as6sg6bipotaab23", result.AlbumUID)
|
2022-08-01 15:57:19 +02:00
|
|
|
assert.Equal(t, "pest&dogs", result.AlbumSlug)
|
|
|
|
}
|
2024-01-05 16:31:07 +01:00
|
|
|
if cached, err := CachedAlbumByUID("as6sg6bipotaab23"); err != nil {
|
2022-08-01 15:57:19 +02:00
|
|
|
t.Fatal(err)
|
|
|
|
} else {
|
2024-01-05 16:31:07 +01:00
|
|
|
assert.Equal(t, "as6sg6bipotaab23", cached.AlbumUID)
|
2022-08-01 15:57:19 +02:00
|
|
|
assert.Equal(t, "pest&dogs", cached.AlbumSlug)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|