34 lines
502 B
Go
34 lines
502 B
Go
|
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!")
|
||
|
}
|
||
|
}
|