photoprism/internal/models/album_test.go

26 lines
607 B
Go
Raw Normal View History

2019-07-16 12:44:13 +02:00
package models
import (
"github.com/gosimple/slug"
2019-07-16 12:44:13 +02:00
"github.com/stretchr/testify/assert"
"testing"
"time"
2019-07-16 12:44:13 +02:00
)
func TestNewAlbum(t *testing.T) {
t.Run("name Christmas 2018", func(t *testing.T) {
album := NewAlbum("Christmas 2018")
assert.Equal(t, "Christmas 2018", album.AlbumName)
assert.Equal(t, "christmas-2018", album.AlbumSlug)
})
t.Run("name empty", func(t *testing.T) {
album := NewAlbum("")
defaultName := time.Now().Format("January 2006")
defaultSlug := slug.Make(defaultName)
assert.Equal(t, defaultName, album.AlbumName)
assert.Equal(t, defaultSlug, album.AlbumSlug)
2019-07-16 12:44:13 +02:00
})
}