mirror of
https://git.sr.ht/~phw/scotty
synced 2025-05-10 02:07:05 +02:00
JSPF: Implemented export as loves and listens
This commit is contained in:
parent
cfc3cd522d
commit
a645ec5c78
6 changed files with 225 additions and 42 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright © 2023 Philipp Wolfer <phw@uploadedlobster.com>
|
||||
Copyright © 2023-2025 Philipp Wolfer <phw@uploadedlobster.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -26,6 +26,7 @@ import (
|
|||
"bytes"
|
||||
"fmt"
|
||||
"log"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"go.uploadedlobster.com/scotty/pkg/jspf"
|
||||
|
@ -38,7 +39,7 @@ func ExampleMusicBrainzTrackExtension() {
|
|||
Tracks: []jspf.Track{
|
||||
{
|
||||
Title: "Oweynagat",
|
||||
Extension: map[string]any{
|
||||
Extension: jspf.ExtensionMap{
|
||||
jspf.MusicBrainzTrackExtensionID: jspf.MusicBrainzTrackExtension{
|
||||
AddedAt: time.Date(2023, 11, 24, 07, 47, 50, 0, time.UTC),
|
||||
AddedBy: "scotty",
|
||||
|
@ -72,3 +73,29 @@ func ExampleMusicBrainzTrackExtension() {
|
|||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
func TestExtensionMapGet(t *testing.T) {
|
||||
ext := jspf.ExtensionMap{
|
||||
jspf.MusicBrainzTrackExtensionID: jspf.MusicBrainzTrackExtension{
|
||||
AddedAt: time.Date(2023, 11, 24, 07, 47, 50, 0, time.UTC),
|
||||
AddedBy: "scotty",
|
||||
},
|
||||
}
|
||||
var trackExt jspf.MusicBrainzTrackExtension
|
||||
err := ext.Get(jspf.MusicBrainzTrackExtensionID, &trackExt)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if trackExt.AddedBy != "scotty" {
|
||||
t.Fatalf("expected 'scotty', got '%s'", trackExt.AddedBy)
|
||||
}
|
||||
}
|
||||
|
||||
func TestExtensionMapGetNotFound(t *testing.T) {
|
||||
ext := jspf.ExtensionMap{}
|
||||
var trackExt jspf.MusicBrainzTrackExtension
|
||||
err := ext.Get(jspf.MusicBrainzTrackExtensionID, &trackExt)
|
||||
if err == nil {
|
||||
t.Fatal("expected ExtensionMap.Get to return an error")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue