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

Function TestStoreRemote

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

Source from the content-addressed store, hash-verified

9)
10
11func TestStoreRemote(t *testing.T) {
12 nodes, err := connectedTestNodes(2, 1)
13 defer tearDownNodes(nodes)
14 if err != nil {
15 t.Fatalf("connectedTestNodes(2, 1) failed: %v", err)
16 }
17
18 n1 := nodes[0]
19 n2 := nodes[1]
20
21 expV := []byte("bar")
22 args := StorageArgs{
23 Key: "foo",
24 Value: expV,
25 Flags: 0,
26 Exp: 0,
27 ExplicitPeer: n2.name,
28 }
29
30 var resp struct{}
31 if err := n1.server.Set(args, &resp); err != nil {
32 t.Errorf("Set(%+v) returned an error: %v", args, err)
33 }
34
35 // Check the key is actually stored.
36 data, err := n2.data.Get(args.Key)
37 if err != nil {
38 t.Errorf("n2.data.Get(%v) returned error: %v", args.Key, err)
39 t.FailNow()
40 }
41
42 if !reflect.DeepEqual(data.Data, expV) {
43 t.Errorf("Stored incorrect value: want %v; got %v", expV, data.Data)
44 }
45}
46
47func TestCasRemoteInvalidRemote(t *testing.T) {
48 nodes, err := connectedTestNodes(2, 1)

Callers

nothing calls this directly

Calls 4

connectedTestNodesFunction · 0.85
tearDownNodesFunction · 0.85
SetMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected