Initial cloud-services repo - gateway service + pkg modules
This commit is contained in:
33
pkg/health/tmobile_test.go
Normal file
33
pkg/health/tmobile_test.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package health_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"fiskerinc.com/modules/health"
|
||||
"fiskerinc.com/modules/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
|
||||
}
|
||||
Reference in New Issue
Block a user