2020-05-22 16:29:12 +02:00
|
|
|
package entity
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestNewFolder(t *testing.T) {
|
|
|
|
t.Run("2020/05", func(t *testing.T) {
|
2020-05-24 22:16:06 +02:00
|
|
|
folder := NewFolder(RootOriginals, "2020/05", nil)
|
|
|
|
assert.Equal(t, RootOriginals, folder.Root)
|
2020-05-22 16:29:12 +02:00
|
|
|
assert.Equal(t, "2020/05", folder.Path)
|
|
|
|
assert.Equal(t, "May 2020", folder.FolderTitle)
|
|
|
|
assert.Equal(t, "", folder.FolderDescription)
|
|
|
|
assert.Equal(t, "", folder.FolderType)
|
|
|
|
assert.Equal(t, SortOrderName, folder.FolderOrder)
|
2020-05-23 20:58:58 +02:00
|
|
|
assert.IsType(t, "", folder.FolderUID)
|
2020-05-22 16:29:12 +02:00
|
|
|
assert.Equal(t, false, folder.FolderFavorite)
|
|
|
|
assert.Equal(t, false, folder.FolderIgnore)
|
|
|
|
assert.Equal(t, false, folder.FolderWatch)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("/2020/05/01/", func(t *testing.T) {
|
2020-05-24 22:16:06 +02:00
|
|
|
folder := NewFolder(RootOriginals, "/2020/05/01/", nil)
|
2020-05-22 16:29:12 +02:00
|
|
|
assert.Equal(t, "2020/05/01", folder.Path)
|
|
|
|
assert.Equal(t, "May 2020", folder.FolderTitle)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("/2020/05/23/", func(t *testing.T) {
|
2020-05-24 22:16:06 +02:00
|
|
|
folder := NewFolder(RootImport, "/2020/05/23/", nil)
|
2020-05-22 16:29:12 +02:00
|
|
|
assert.Equal(t, "2020/05/23", folder.Path)
|
|
|
|
assert.Equal(t, "May 23, 2020", folder.FolderTitle)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("/2020/05/23 Birthday", func(t *testing.T) {
|
2020-05-24 22:16:06 +02:00
|
|
|
folder := NewFolder(RootOriginals, "/2020/05/23 Birthday", nil)
|
2020-05-22 16:29:12 +02:00
|
|
|
assert.Equal(t, "2020/05/23 Birthday", folder.Path)
|
|
|
|
assert.Equal(t, "23 Birthday", folder.FolderTitle)
|
|
|
|
})
|
|
|
|
|
2020-05-22 19:05:16 +02:00
|
|
|
t.Run("empty", func(t *testing.T) {
|
2020-05-24 22:16:06 +02:00
|
|
|
folder := NewFolder(RootOriginals, "", nil)
|
2020-05-22 19:05:16 +02:00
|
|
|
assert.Equal(t, "", folder.Path)
|
|
|
|
assert.Equal(t, "Originals", folder.FolderTitle)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("root", func(t *testing.T) {
|
2020-05-24 22:16:06 +02:00
|
|
|
folder := NewFolder(RootOriginals, RootPath, nil)
|
2020-05-22 19:05:16 +02:00
|
|
|
assert.Equal(t, "", folder.Path)
|
2020-05-22 16:29:12 +02:00
|
|
|
assert.Equal(t, "Originals", folder.FolderTitle)
|
|
|
|
})
|
|
|
|
}
|