MCPcopy
hub / github.com/ha/doozerd / TestDoozerGetWithRev

Function TestDoozerGetWithRev

src/pkg/peer/peer_test.go:77–107  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

75
76
77func TestDoozerGetWithRev(t *testing.T) {
78 l := mustListen()
79 defer l.Close()
80 u := mustListenUDP(l.Addr().String())
81 defer u.Close()
82
83 go Main("a", "X", "", "", "", nil, u, l, nil, 1e9, 2e9, 3e9, 101)
84
85 cl := dial(l.Addr().String())
86
87 rev1, err := cl.Set("/x", store.Missing, []byte{'a'})
88 assert.Equal(t, nil, err)
89
90 v, rev, err := cl.Get("/x", &rev1) // Use the snapshot.
91 assert.Equal(t, nil, err)
92 assert.Equal(t, rev1, rev)
93 assert.Equal(t, []byte{'a'}, v)
94
95 rev2, err := cl.Set("/x", rev, []byte{'b'})
96 assert.Equal(t, nil, err)
97
98 v, rev, err = cl.Get("/x", nil) // Read the new value.
99 assert.Equal(t, nil, err)
100 assert.Equal(t, rev2, rev)
101 assert.Equal(t, []byte{'b'}, v)
102
103 v, rev, err = cl.Get("/x", &rev1) // Read the saved value again.
104 assert.Equal(t, nil, err)
105 assert.Equal(t, rev1, rev)
106 assert.Equal(t, []byte{'a'}, v)
107}
108
109
110func TestDoozerWaitSimple(t *testing.T) {

Callers

nothing calls this directly

Calls 7

mustListenFunction · 0.85
mustListenUDPFunction · 0.85
MainFunction · 0.85
dialFunction · 0.85
SetMethod · 0.80
GetMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected