package health_test import ( "context" "testing" "github.com/fiskerinc/cloud-services/pkg/health" "github.com/fiskerinc/cloud-services/pkg/testhelper" "github.com/pkg/errors" ) func TestClickhouseCheck(t *testing.T) { mock := MockClickhouseDB{} fn := func() (health.ClickhouseConnCheckInterface, error) { return &mock, nil } check := health.NewClickhouseCheck(fn) err := check(context.Background()) testhelper.NoError(t, "No error", err) mock.Error = errors.New("ping error") err = check(context.Background()) testhelper.Error(t, "Ping error", err) } type MockClickhouseDB struct { Error error } func (m *MockClickhouseDB) Ping(ctx context.Context) error { return m.Error }