From b7e1bd3845b9d2ecfad626bc2e10a752306e3757 Mon Sep 17 00:00:00 2001
From: Vladimir Popov <vladimir.popov@xored.com>
Date: Tue, 6 Apr 2021 16:25:34 +0700
Subject: [PATCH] Remove clockMock.IsTimerSet

Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>
---
 .../common/refresh/nse_registry_client_test.go      |  8 ++++----
 pkg/tools/clockmock/mock.go                         | 13 -------------
 2 files changed, 4 insertions(+), 17 deletions(-)

diff --git a/pkg/registry/common/refresh/nse_registry_client_test.go b/pkg/registry/common/refresh/nse_registry_client_test.go
index f0f27457b4..0588be6219 100644
--- a/pkg/registry/common/refresh/nse_registry_client_test.go
+++ b/pkg/registry/common/refresh/nse_registry_client_test.go
@@ -69,7 +69,7 @@ func TestNewNetworkServiceEndpointRegistryClient(t *testing.T) {
 	require.NoError(t, err)
 
 	// Wait for the Refresh goroutine to start
-	require.Eventually(t, clockMock.IsTimerSet, testWait, testTick)
+	time.Sleep(testTick)
 
 	clockMock.Add(expireTimeout)
 	require.Eventually(t, func() bool {
@@ -118,7 +118,7 @@ func Test_RefreshNSEClient_CalledRegisterTwice(t *testing.T) {
 	require.NoError(t, err)
 
 	// Wait for the Refresh goroutine to start
-	require.Eventually(t, clockMock.IsTimerSet, testWait, testTick)
+	time.Sleep(testTick)
 
 	clockMock.Add(expireTimeout)
 	require.Eventually(t, func() bool {
@@ -163,7 +163,7 @@ func Test_RefreshNSEClient_ShouldOverrideNameAndDuration(t *testing.T) {
 	require.NoError(t, err)
 
 	// Wait for the Refresh goroutine to start
-	require.Eventually(t, clockMock.IsTimerSet, testWait, testTick)
+	time.Sleep(testTick)
 
 	for i := 1; i <= 3; i++ {
 		count := int32(i)
@@ -202,7 +202,7 @@ func Test_RefreshNSEClient_SetsCorrectExpireTime(t *testing.T) {
 	require.NoError(t, err)
 
 	// Wait for the Refresh goroutine to start
-	require.Eventually(t, clockMock.IsTimerSet, testWait, testTick)
+	time.Sleep(testTick)
 
 	for i := 1; i <= 3; i++ {
 		count := int32(i)
diff --git a/pkg/tools/clockmock/mock.go b/pkg/tools/clockmock/mock.go
index 89db96268b..98362d0064 100644
--- a/pkg/tools/clockmock/mock.go
+++ b/pkg/tools/clockmock/mock.go
@@ -20,7 +20,6 @@ package clockmock
 import (
 	"context"
 	"sync"
-	"sync/atomic"
 	"time"
 
 	libclock "github.com/benbjohnson/clock"
@@ -34,7 +33,6 @@ var _ clock.Clock = (*Mock)(nil)
 type Mock struct {
 	lock sync.RWMutex
 	mock *libclock.Mock
-	flag int32
 }
 
 // NewMock returns a new mocked clock
@@ -44,11 +42,6 @@ func NewMock() *Mock {
 	}
 }
 
-// IsTimerSet returns if any timer/ticker has ever been set on mock.
-func (m *Mock) IsTimerSet() bool {
-	return atomic.LoadInt32(&m.flag) != 0
-}
-
 // Set sets the current time of the mock clock to a specific one.
 // This should only be called from a single goroutine at a time.
 func (m *Mock) Set(t time.Time) {
@@ -89,8 +82,6 @@ func (m *Mock) Sleep(d time.Duration) {
 
 // Timer returns a timer that will fire when the mock current time becomes > m.Now().Add(d)
 func (m *Mock) Timer(d time.Duration) clock.Timer {
-	defer atomic.StoreInt32(&m.flag, 1)
-
 	m.lock.RLock()
 	defer m.lock.RUnlock()
 
@@ -113,8 +104,6 @@ func (m *Mock) AfterFunc(d time.Duration, f func()) clock.Timer {
 }
 
 func (m *Mock) afterFunc(d time.Duration, f func()) clock.Timer {
-	defer atomic.StoreInt32(&m.flag, 1)
-
 	return &mockTimer{
 		Timer: m.mock.AfterFunc(safeDuration(d), func() {
 			go f()
@@ -124,8 +113,6 @@ func (m *Mock) afterFunc(d time.Duration, f func()) clock.Timer {
 
 // Ticker returns a ticker that will fire every time when the mock current time becomes > mock previous time + d
 func (m *Mock) Ticker(d time.Duration) clock.Ticker {
-	defer atomic.StoreInt32(&m.flag, 1)
-
 	m.lock.RLock()
 	defer m.lock.RUnlock()