(t *testing.T)
| 117 | } |
| 118 | |
| 119 | func 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 | |
| 154 | func TestTouchRemoteInvalid(t *testing.T) { |
| 155 | nodes, err := connectedTestNodes(2, 1) |
nothing calls this directly
no test coverage detected