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 TestTmobileCheck(t *testing.T) {
	mock := MockTmobile{}
	fn := func() (health.TmobileConnCheckInterface, error) {
		return &mock, nil
	}
	check := health.NewTmobileCheck(fn)

	err := check(context.Background())
	testhelper.NoError(t, "No error", err)

	mock.PingError = errors.New("ping error")
	err = check(context.Background())
	testhelper.Error(t, "Ping error", err)
}

type MockTmobile struct {
	PingError error
}

func (m *MockTmobile) Ping(ctx context.Context) error {
	return m.PingError
}
