mirror of
https://github.com/coredns/coredns.git
synced 2026-09-01 09:37:05 -04:00
24 lines
574 B
Go
24 lines
574 B
Go
|
|
package cache
|
||
|
|
|
||
|
|
import (
|
||
|
|
"reflect"
|
||
|
|
"testing"
|
||
|
|
"time"
|
||
|
|
|
||
|
|
"github.com/miekg/dns"
|
||
|
|
)
|
||
|
|
|
||
|
|
func TestNewItemPreservesMonotonicClock(t *testing.T) {
|
||
|
|
now := time.Now()
|
||
|
|
if reflect.DeepEqual(now, now.Round(0)) {
|
||
|
|
t.Fatal("time.Now did not include a monotonic clock reading")
|
||
|
|
}
|
||
|
|
i := newItem(new(dns.Msg), now, time.Minute)
|
||
|
|
|
||
|
|
// DeepEqual compares the complete time representation, including its
|
||
|
|
// monotonic clock reading. Time.Equal intentionally ignores that detail.
|
||
|
|
if !reflect.DeepEqual(i.stored, now) {
|
||
|
|
t.Fatalf("stored time = %v; want original time %v", i.stored, now)
|
||
|
|
}
|
||
|
|
}
|