MCPcopy Create free account
hub / github.com/dadgar/onecache / TestMarkTouched

Function TestMarkTouched

onecache/replicator_test.go:311–347  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

309}
310
311func TestMarkTouched(t *testing.T) {
312 nodes, err := connectedTestNodes(2, 2)
313 defer tearDownNodes(nodes)
314 if err != nil {
315 t.Fatalf("connectedTestNodes(2, 2) failed: %v", err)
316 }
317
318 // Store a key on both nodes but with different experations.
319 k := "foo"
320 owner, followers := getOwner(k, nodes)
321 follower := followers[0]
322 exp := time.Now().Add(1 * time.Hour).Unix()
323 if err := owner.data.Set(k, []byte("bar"), exp, 0); err != nil {
324 t.Fatalf("Set(%v) failed: %v", k, err)
325 }
326
327 if err := follower.data.Set(k, []byte("bar"), 0, 0); err != nil {
328 t.Fatalf("Set(%v) failed: %v", k, err)
329 }
330
331 owner.replicator.MarkTouched(k)
332
333 // Check the key expiration is updated.
334 waitForResult(func() (bool, error) {
335 data, err := follower.data.Get(k)
336 if err != nil {
337 return false, nil
338 }
339
340 if data.Exp != exp {
341 return false, nil
342 }
343 return true, nil
344 }, func(e error) {
345 t.Errorf("Replication failed: %v", e)
346 })
347}
348
349func TestCollapseLogValueTouch(t *testing.T) {
350 in := []replicationTask{task_DIRTY_VALUE, task_TOUCH}

Callers

nothing calls this directly

Calls 8

connectedTestNodesFunction · 0.85
tearDownNodesFunction · 0.85
getOwnerFunction · 0.85
waitForResultFunction · 0.85
MarkTouchedMethod · 0.65
AddMethod · 0.45
SetMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected