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

Function TestTouchRemote

onecache/onecache_rpc_test.go:119–152  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

117}
118
119func TestTouchRemote(t *testing.T) {
120 nodes, err := connectedTestNodes(2, 1)
121 defer tearDownNodes(nodes)
122 if err != nil {
123 t.Fatalf("connectedTestNodes(2, 1) failed: %v", err)
124 }
125
126 n1 := nodes[0]
127 n2 := nodes[1]
128
129 // Store a value on the second node
130 k := "foo"
131 if err := n2.data.Set(k, []byte("bar"), 0, 0); err != nil {
132 t.Fatalf("Set(%v) failed: %v", k, err)
133 }
134
135 var resp struct{}
136 var exp int64 = time.Now().Add(1 * time.Hour).Unix()
137 args := StorageArgs{Key: k, Exp: exp, ExplicitPeer: n2.name}
138 if err := n1.server.Touch(args, &resp); err != nil {
139 t.Errorf("Touch(%+v) returned an error %v", args, err)
140 }
141
142 // Check the new experation is correct.
143 data, err := n2.data.Get(k)
144 if err != nil {
145 t.Errorf("Get(%v) failed: %v", k, err)
146 t.FailNow()
147 }
148
149 if data.Exp != exp {
150 t.Errorf("Experation is %v; want %v", data.Exp, exp)
151 }
152}
153
154func TestTouchRemoteInvalid(t *testing.T) {
155 nodes, err := connectedTestNodes(2, 1)

Callers

nothing calls this directly

Calls 6

connectedTestNodesFunction · 0.85
tearDownNodesFunction · 0.85
SetMethod · 0.45
AddMethod · 0.45
TouchMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected