Use MBID type from go.uploadedlobster.com/mbtypes

This commit is contained in:
Philipp Wolfer 2025-04-03 14:56:39 +02:00
parent 04eddfda33
commit 8fff19ceac
No known key found for this signature in database
GPG key ID: 8FDF744D4919943B
12 changed files with 82 additions and 188 deletions

View file

@ -30,6 +30,7 @@ import (
"strings"
"time"
"go.uploadedlobster.com/mbtypes"
"go.uploadedlobster.com/scotty/internal/models"
)
@ -203,7 +204,7 @@ func rowToListen(row []string, client string) (models.Listen, error) {
}
if len(row) > 7 {
listen.Track.RecordingMbid = models.MBID(row[7])
listen.Track.RecordingMbid = mbtypes.MBID(row[7])
}
return listen, nil

View file

@ -30,6 +30,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.uploadedlobster.com/mbtypes"
"go.uploadedlobster.com/scotty/internal/backends/scrobblerlog"
"go.uploadedlobster.com/scotty/internal/models"
)
@ -60,10 +61,10 @@ func TestParser(t *testing.T) {
assert.Equal(time.Duration(306*time.Second), listen1.Duration)
assert.Equal("L", listen1.AdditionalInfo["rockbox_rating"])
assert.Equal(time.Unix(1260342084, 0), listen1.ListenedAt)
assert.Equal(models.MBID(""), listen1.RecordingMbid)
assert.Equal(mbtypes.MBID(""), listen1.RecordingMbid)
listen4 := result.Listens[3]
assert.Equal("S", listen4.AdditionalInfo["rockbox_rating"])
assert.Equal(models.MBID("385ba9e9-626d-4750-a607-58e541dca78e"), listen4.RecordingMbid)
assert.Equal(mbtypes.MBID("385ba9e9-626d-4750-a607-58e541dca78e"), listen4.RecordingMbid)
}
func TestParserExcludeSkipped(t *testing.T) {
@ -74,7 +75,7 @@ func TestParserExcludeSkipped(t *testing.T) {
assert.Len(result.Listens, 4)
listen4 := result.Listens[3]
assert.Equal("L", listen4.AdditionalInfo["rockbox_rating"])
assert.Equal(models.MBID("1262beaf-19f8-4534-b9ed-7eef9ca8e83f"), listen4.RecordingMbid)
assert.Equal(mbtypes.MBID("1262beaf-19f8-4534-b9ed-7eef9ca8e83f"), listen4.RecordingMbid)
}
func TestWrite(t *testing.T) {
@ -93,7 +94,7 @@ func TestWrite(t *testing.T) {
TrackName: "Reign",
TrackNumber: 1,
Duration: 271 * time.Second,
RecordingMbid: models.MBID("b59cf4e7-caee-4019-a844-79d2c58d4dff"),
RecordingMbid: mbtypes.MBID("b59cf4e7-caee-4019-a844-79d2c58d4dff"),
AdditionalInfo: models.AdditionalInfo{"rockbox_rating": "L"},
},
},