-
Notifications
You must be signed in to change notification settings - Fork 1
/
meta_test.go
51 lines (42 loc) · 1003 Bytes
/
meta_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package prophet
import (
"testing"
)
func TestPeerClone(t *testing.T) {
old := newTestPeer(1, 10)
cloned := old.Clone()
if cloned.ID != old.ID {
t.Error("peer clone failed with ID")
}
if cloned.ContainerID != old.ContainerID {
t.Error("peer clone failed with ContainerID")
}
old.ID = 2
old.ContainerID = 20
if cloned.ID == old.ID {
t.Error("peer clone failed with ID changed")
}
if cloned.ContainerID == old.ContainerID {
t.Error("peer clone failed with ContainerID changed")
}
}
func TestPeerStatusClone(t *testing.T) {
old := &PeerStats{
Peer: newTestPeer(1, 10),
DownSeconds: 10,
}
cloned := old.Clone()
if cloned.DownSeconds != old.DownSeconds {
t.Error("peer status clone failed with DownSeconds")
}
old.DownSeconds = 20
if cloned.DownSeconds == old.DownSeconds {
t.Error("peer status clone failed with DownSeconds changed")
}
}
func newTestPeer(id, containerID uint64) *Peer {
return &Peer{
ID: id,
ContainerID: containerID,
}
}