-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnode_test.go
33 lines (29 loc) · 909 Bytes
/
node_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
package main
import (
"testing"
"time"
)
func Test_newNode(t *testing.T) {
n := newNode("testuuid", "http://localhost:1000", true)
if n.UUID != "testuuid" {
t.Error("node wasn't created properly")
}
}
func Test_DateFormatting(t *testing.T) {
n := newNode("testuuid", "http://localhost:1000", true)
n.LastSeen, _ = time.Parse("Mon Jan 2 15:04:05 -0700 MST 2006", "Mon Jan 2 15:04:05 -0700 MST 2006")
if n.LastSeenFormatted() != "2006-01-02 15:04:05" {
t.Error("wrong formatted date for LastSeen")
}
n.LastFailed, _ = time.Parse("Mon Jan 2 15:04:05 -0700 MST 2006", "Mon Jan 2 15:04:05 -0700 MST 2006")
if n.LastFailedFormatted() != "2006-01-02 15:04:05" {
t.Error("wrong formatted date for LastFailed")
}
}
func Test_HashKeys(t *testing.T) {
n := newNode("testuuid", "http://localhost:1000", true)
keys := n.HashKeys()
if len(keys) != replicas {
t.Error("wrong number of keys")
}
}