controlclient: adjust user expiry test

Signed-off-by: David Crawshaw <crawshaw@tailscale.com>
This commit is contained in:
David Crawshaw 2020-02-26 09:44:42 -05:00
parent eefafad9f8
commit 6879581891

View File

@ -741,16 +741,15 @@ func TestNewUserWebFlow(t *testing.T) {
if len(peers) != 1 { if len(peers) != 1 {
t.Errorf("len(peers)=%d, want 1", len(peers)) t.Errorf("len(peers)=%d, want 1", len(peers))
} }
var nodeExp time.Time
if nodes, err := s.control.DB().AllNodes(netmap.User); err != nil { if nodes, err := s.control.DB().AllNodes(netmap.User); err != nil {
t.Fatal(err) t.Fatal(err)
} else if len(nodes) != 1 { } else if len(nodes) != 1 {
t.Errorf("len(nodes)=%d, want 1", len(nodes)) t.Errorf("len(nodes)=%d, want 1", len(nodes))
} else if exp := nodes[0].KeyExpiry; exp.After(c.timeNow()) { } else if nodeExp = nodes[0].KeyExpiry; c.timeNow().Sub(nodeExp) > 24*time.Hour {
t.Errorf("node[0] expiry=%v, want it to have passed", exp) t.Errorf("node[0] expiry=%v, want it to be in less than a day", nodeExp)
} } else if got := c.status(t).New.NetMap.Expiry; !got.Equal(nodeExp) {
netmap := c.status(t).New.NetMap t.Errorf("expiry=%v, want it to be %v", got, nodeExp)
if exp := netmap.Expiry; exp.After(c.timeNow()) {
t.Errorf("expiry=%v, want it to have passed", exp)
} }
}) })
} }