mirror of
https://git.sr.ht/~phw/scotty
synced 2025-04-25 13:57:56 +02:00
Updated all import/export interfaces
This commit is contained in:
parent
729a3d0ed0
commit
ab04eb1123
12 changed files with 247 additions and 167 deletions
|
@ -27,6 +27,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.uploadedlobster.com/scotty/models"
|
||||
)
|
||||
|
||||
|
@ -41,7 +42,7 @@ func TestTrackArtistName(t *testing.T) {
|
|||
assert.Equal(t, "Foo, Bar, Baz", track.ArtistName())
|
||||
}
|
||||
|
||||
func TestListensListSort(t *testing.T) {
|
||||
func TestListensListNewerThan(t *testing.T) {
|
||||
listen1 := models.Listen{ListenedAt: time.Unix(3, 0)}
|
||||
listen2 := models.Listen{ListenedAt: time.Unix(0, 0)}
|
||||
listen3 := models.Listen{ListenedAt: time.Unix(2, 0)}
|
||||
|
@ -52,6 +53,19 @@ func TestListensListSort(t *testing.T) {
|
|||
assert.Equal(t, listen3, list[1])
|
||||
}
|
||||
|
||||
func TestListensListSort(t *testing.T) {
|
||||
now := time.Now()
|
||||
listen1 := models.Listen{UserName: "l1", ListenedAt: now.Add(-1 * time.Hour)}
|
||||
listen2 := models.Listen{UserName: "l2", ListenedAt: now}
|
||||
listen3 := models.Listen{UserName: "l3", ListenedAt: now.Add(1 * time.Hour)}
|
||||
listen4 := models.Listen{UserName: "l4", ListenedAt: now.Add(2 * time.Hour)}
|
||||
list := models.ListensList{listen1, listen2, listen3, listen4}
|
||||
newList := list.NewerThan(now)
|
||||
require.Len(t, newList, 2)
|
||||
assert.Equal(t, listen3, newList[0])
|
||||
assert.Equal(t, listen4, newList[1])
|
||||
}
|
||||
|
||||
func TestLovesListSort(t *testing.T) {
|
||||
love1 := models.Love{Created: time.Unix(3, 0)}
|
||||
love2 := models.Love{Created: time.Unix(0, 0)}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue