...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package cache
17
18 import (
19 "reflect"
20 "testing"
21
22 core "github.com/datawire/ambassador/v2/pkg/api/envoy/config/core/v3"
23 )
24
25 func TestIDHash(t *testing.T) {
26 node := &core.Node{Id: "test"}
27 if got := (IDHash{}).ID(node); got != "test" {
28 t.Errorf("IDHash.ID(%v) => got %s, want %s", node, got, node.Id)
29 }
30 if got := (IDHash{}).ID(nil); got != "" {
31 t.Errorf("IDHash.ID(nil) => got %s, want empty", got)
32 }
33 }
34
35 func TestNewStatusInfo(t *testing.T) {
36 node := &core.Node{Id: "test"}
37 info := newStatusInfo(node)
38
39 if got := info.GetNode(); !reflect.DeepEqual(got, node) {
40 t.Errorf("GetNode() => got %#v, want %#v", got, node)
41 }
42
43 if got := info.GetNumWatches(); got != 0 {
44 t.Errorf("GetNumWatches() => got %d, want 0", got)
45 }
46
47 if got := info.GetLastWatchRequestTime(); !got.IsZero() {
48 t.Errorf("GetLastWatchRequestTime() => got %v, want zero time", got)
49 }
50
51 }
52
View as plain text