From a6926169815e03d00f9cfac0417da6f797d539ae Mon Sep 17 00:00:00 2001 From: Simon Zolin Date: Fri, 29 Nov 2019 17:35:26 +0300 Subject: [PATCH] - clients: fix tests --- home/clients.go | 8 ++++++-- home/clients_test.go | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/home/clients.go b/home/clients.go index 4e6486e2..0cc5c65a 100644 --- a/home/clients.go +++ b/home/clients.go @@ -62,6 +62,8 @@ type clientsContainer struct { lock sync.Mutex dhcpServer *dhcpd.Server + + testing bool // if TRUE, this object is used for internal tests } // Init initializes clients container @@ -76,9 +78,11 @@ func (clients *clientsContainer) Init(objects []clientObject, dhcpServer *dhcpd. clients.dhcpServer = dhcpServer clients.addFromConfig(objects) - go clients.periodicUpdate() + if !clients.testing { + go clients.periodicUpdate() - clients.registerWebHandlers() + clients.registerWebHandlers() + } } type clientObject struct { diff --git a/home/clients_test.go b/home/clients_test.go index c830ee34..99a5404d 100644 --- a/home/clients_test.go +++ b/home/clients_test.go @@ -11,6 +11,7 @@ func TestClients(t *testing.T) { var e error var b bool clients := clientsContainer{} + clients.testing = true clients.Init(nil, nil) @@ -149,6 +150,7 @@ func TestClients(t *testing.T) { func TestClientsWhois(t *testing.T) { var c Client clients := clientsContainer{} + clients.testing = true clients.Init(nil, nil) whois := [][]string{{"orgname", "orgname-val"}, {"country", "country-val"}}