Files
cloud-services/pkg/health/clickhouse_test.go

34 lines
663 B
Go

package health_test
import (
"context"
"testing"
"fiskerinc.com/modules/health"
"fiskerinc.com/modules/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
}