예제 #1
0
func ShouldStatMiss(t testing.TB, s store.Store, key string) {
	st, err := s.Stat(key, nil)
	if err != store.ErrNotFound {
		t.Errorf("Stat(%#v) returned (%v, %v), but wanted %v",
			key, st, err, store.ErrNotFound)
	}
}
예제 #2
0
func ShouldStatNoTime(t testing.TB, s store.Store, key string, stat store.Stat) {
	st, err := s.Stat(key, nil)
	if err != nil {
		t.Errorf("Stat(%#v) returned unexpected error %v", key, err)
		return
	}
	stat.WriteTime = st.WriteTime
	if st != stat {
		t.Errorf("Stat(%#v) = %#v, but wanted %#v", key, st, stat)
	}
}
예제 #3
0
파일: generic.go 프로젝트: encryptio/slime
func TestStoreWriteTime(t *testing.T, s store.Store) {
	t.Logf("TestStoreWriteTime()")

	ShouldCAS(t, s, "key", store.AnyV, store.DataV([]byte("one")))
	now := time.Now().Unix()

	st, err := s.Stat("key", nil)
	if err != nil {
		t.Fatalf("Couldn't stat key: %v", err)
	}
	diff := st.WriteTime - now
	if diff < 0 {
		diff = -diff
	}
	if diff > 2 {
		t.Fatalf("Store returned timestamp %v, but wanted %v", st.WriteTime, now)
	}

	ShouldCAS(t, s, "key", store.AnyV, store.MissingV)
}