|
|
@ -76,6 +76,7 @@ func Test_watchdogProvider(t *testing.T) {
|
|
|
|
t.Run(name, func(t *testing.T) {
|
|
|
|
t.Run(name, func(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
t.Parallel()
|
|
|
|
tc := _tc
|
|
|
|
tc := _tc
|
|
|
|
|
|
|
|
ms := time.Duration(len(tc.states)+1) * testInterval
|
|
|
|
provider := NewMockProvider(t)
|
|
|
|
provider := NewMockProvider(t)
|
|
|
|
wd := &watchdogProvider{
|
|
|
|
wd := &watchdogProvider{
|
|
|
|
Provider: provider,
|
|
|
|
Provider: provider,
|
|
|
@ -98,12 +99,8 @@ func Test_watchdogProvider(t *testing.T) {
|
|
|
|
provider.EXPECT().Start().Return(nil).Times(tc.expectedStartCalls)
|
|
|
|
provider.EXPECT().Start().Return(nil).Times(tc.expectedStartCalls)
|
|
|
|
provider.EXPECT().Stop().Return(nil).Once()
|
|
|
|
provider.EXPECT().Stop().Return(nil).Once()
|
|
|
|
|
|
|
|
|
|
|
|
require.False(t, wd.running)
|
|
|
|
|
|
|
|
require.NoError(t, wd.Start())
|
|
|
|
require.NoError(t, wd.Start())
|
|
|
|
require.True(t, wd.running)
|
|
|
|
|
|
|
|
ms := time.Duration(len(tc.states)+1) * testInterval
|
|
|
|
|
|
|
|
<-time.After(ms)
|
|
|
|
<-time.After(ms)
|
|
|
|
require.False(t, wd.running)
|
|
|
|
|
|
|
|
require.ErrorIs(t, wd.Stop(), libscada.ErrProviderNotStarted)
|
|
|
|
require.ErrorIs(t, wd.Stop(), libscada.ErrProviderNotStarted)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|