1
0
Fork 0
mirror of https://github.com/kyverno/policy-reporter.git synced 2024-12-14 11:57:32 +00:00
policy-reporter/pkg/config/readinessprobe_test.go
Frank Jogeleit 72abc63ce0
External SQL DB support (#304)
* Support external Databases

Signed-off-by: Frank Jogeleit <frank.jogeleit@web.de>
2023-05-02 11:00:14 +02:00

53 lines
1.1 KiB
Go

package config_test
import (
"testing"
"github.com/kyverno/policy-reporter/pkg/config"
)
func Test_ReadinessProbe(t *testing.T) {
t.Run("immediate return without REST enabled", func(t *testing.T) {
rdy := config.NewReadinessProbe(
&config.Config{
REST: config.REST{Enabled: false},
LeaderElection: config.LeaderElection{Enabled: false},
},
)
rdy.Wait()
})
t.Run("immediate return without LeaderElection enabled", func(t *testing.T) {
rdy := config.NewReadinessProbe(
&config.Config{
REST: config.REST{Enabled: true},
LeaderElection: config.LeaderElection{Enabled: false},
},
)
rdy.Wait()
})
t.Run("wait for ready state", func(t *testing.T) {
rdy := config.NewReadinessProbe(
&config.Config{
REST: config.REST{Enabled: true},
LeaderElection: config.LeaderElection{Enabled: true},
},
)
if rdy.Running() {
t.Error("should not be running until ready was called")
}
go func() {
rdy.Wait()
if !rdy.Running() {
t.Error("should be running after ready was called")
}
}()
rdy.Ready()
})
}