truckstop/config/time_test.go

23 lines
428 B
Go

package config
import (
"encoding/json"
"testing"
"time"
)
func TestTimeMarshal(t *testing.T) {
now := time.Now()
nowt := Time(now)
var other Time
if b, err := json.Marshal(nowt); err != nil {
t.Fatal(err)
} else if len(b) < 5 {
t.Fatal(string(b))
} else if err := json.Unmarshal(b, &other); err != nil {
t.Fatal(err)
} else if now.Unix() != other.Get().Unix() {
t.Fatal(other.Get().Unix(), now.Unix())
}
}