package timeutil

import (
	"encoding/json"
	"testing"
)

func TestDuration(t *testing.T) {
	js := []byte(`{"foo": "30s"}`)

	foo := struct{ Foo Duration }{}

	err := json.Unmarshal(js, &foo)
	if err != nil {
		t.Fatalf("could not unmarshal %q: %s", js, err)
	}

	if foo.Foo.Seconds() != 30 {
		t.Fatalf("parsed time.Duration wasn't 30 seconds: %s", foo.Foo)
	}
}