Files
payments/internal/api/services/pools_get_test.go
CrimsonandGitHub 06aae5801a fix(debug): hide dummypay from configs response when not in debug mode (#316)
* fix(debug): hide dummypay connector from configs list unless in debug mode

* Set debug flag to true in integratio test so we can see Dummypay configuration
2025-02-06 15:00:14 +01:00

63 lines
1.4 KiB
Go

package services
import (
"context"
"fmt"
"testing"
"github.com/formancehq/payments/internal/connectors/engine"
"github.com/formancehq/payments/internal/models"
"github.com/formancehq/payments/internal/storage"
"github.com/google/uuid"
"github.com/stretchr/testify/require"
gomock "go.uber.org/mock/gomock"
)
func TestPoolsGet(t *testing.T) {
t.Parallel()
ctrl := gomock.NewController(t)
defer ctrl.Finish()
store := storage.NewMockStorage(ctrl)
eng := engine.NewMockEngine(ctrl)
s := New(store, eng, false)
id := uuid.New()
tests := []struct {
name string
err error
expectedError error
}{
{
name: "success",
err: nil,
expectedError: nil,
},
{
name: "storage error not found",
err: storage.ErrNotFound,
expectedError: newStorageError(storage.ErrNotFound, "cannot get pool"),
},
{
name: "other error",
err: fmt.Errorf("error"),
expectedError: newStorageError(fmt.Errorf("error"), "cannot get pool"),
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
store.EXPECT().PoolsGet(gomock.Any(), id).Return(&models.Pool{}, test.err)
payment, err := s.PoolsGet(context.Background(), id)
if test.expectedError == nil {
require.NotNil(t, payment)
require.NoError(t, err)
} else {
require.Equal(t, test.expectedError, err)
}
})
}
}