gavalink/model_test.go

34 lines
502 B
Go
Raw Permalink Normal View History

2020-04-12 16:03:08 +00:00
package gavalink
import (
"encoding/json"
"testing"
"time"
)
func TestTrackInfo_JSON(t *testing.T) {
i := &TrackInfo{
Length: 10 * time.Second,
}
b, err := json.Marshal(i)
if err != nil {
t.Fatal(err)
}
t.Log(string(b))
deserialize := &TrackInfo{}
if err = json.Unmarshal(b, &deserialize); err != nil {
t.Fatal(err)
}
t.Log("Deserialized length:", deserialize.Length)
if deserialize.Length != time.Second*10 {
t.Fatal("Expected deserialized time to be 10 seconds!")
}
}