Add test for entity/album.go
This commit is contained in:
parent
380bc4ec6c
commit
1b78ae2513
1 changed files with 20 additions and 0 deletions
|
@ -24,3 +24,23 @@ func TestNewAlbum(t *testing.T) {
|
|||
assert.Equal(t, defaultSlug, album.AlbumSlug)
|
||||
})
|
||||
}
|
||||
|
||||
func TestRename(t *testing.T) {
|
||||
t.Run("valid name", func(t *testing.T) {
|
||||
album := NewAlbum("initial name")
|
||||
assert.Equal(t, "initial name", album.AlbumName)
|
||||
assert.Equal(t, "initial-name", album.AlbumSlug)
|
||||
album.Rename("new album name")
|
||||
assert.Equal(t, "new album name", album.AlbumName)
|
||||
assert.Equal(t, "new-album-name", album.AlbumSlug)
|
||||
})
|
||||
t.Run("empty name", func(t *testing.T) {
|
||||
album := NewAlbum("initial name")
|
||||
assert.Equal(t, "initial name", album.AlbumName)
|
||||
assert.Equal(t, "initial-name", album.AlbumSlug)
|
||||
t.Log(album.CreatedAt)
|
||||
album.Rename("")
|
||||
assert.Equal(t, "January 0001", album.AlbumName)
|
||||
assert.Equal(t, "january-0001", album.AlbumSlug)
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue