Initial cloud-services repo - gateway service + pkg modules

This commit is contained in:
Chris Rai
2026-01-30 23:14:52 -05:00
commit fbb820d7b3
1037 changed files with 171318 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
package health_test
import (
"context"
"testing"
"fiskerinc.com/modules/health"
"fiskerinc.com/modules/testhelper"
"github.com/go-pg/pg/v10/orm"
"github.com/pkg/errors"
)
func TestPostgresCheck(t *testing.T) {
mock := MockPostgres{}
check := health.NewPostgresCheck(&mock)
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 MockPostgres struct {
OrmResult orm.Result
PingError error
ExecError error
}
func (m *MockPostgres) Ping(ctx context.Context) error {
return m.PingError
}
func (m *MockPostgres) Exec(query interface{}, params ...interface{}) (res orm.Result, err error) {
return m.OrmResult, m.ExecError
}