mirror of
https://github.com/hanzo-fi/payments.git
synced 2026-10-30 20:31:20 +00:00
* feat(EN-208): enable default & minimum polling period specifically for Stripe * feat(EN-208): update openAPI + fix compile-configs tool to support Durations * feat(EN-208): created helper type for period so it's easier to generalize * feat(EN-208): enable pollingPeriod for atlar * feat(EN-208): same treatment for bankingbridge * feat(EN-208): change column * feat(EN-208): added pollingPeriod for generic. * feat(EN-208): increase, couldn't connecto properly * feat(EN-208): added pollingPeriod for mangopay, modulr, moneycorp, qonto and wise * feat(EN-208): fixed openapi and sdk * fix: change global default/min pollingPeriod * fix: e2e tests
69 lines
1.9 KiB
Go
69 lines
1.9 KiB
Go
package column
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/formancehq/payments/internal/connectors/plugins/sharedconfig"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestUnmarshalAndValidateConfig(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
defaultPollingPeriod, _ := sharedconfig.NewPollingPeriod("", sharedconfig.DefaultPollingPeriod, sharedconfig.MinimumPollingPeriod)
|
|
longPollingPeriod, _ := sharedconfig.NewPollingPeriod("45m", sharedconfig.DefaultPollingPeriod, sharedconfig.MinimumPollingPeriod)
|
|
|
|
tests := []struct {
|
|
name string
|
|
payload []byte
|
|
expected Config
|
|
expectError bool
|
|
}{
|
|
{
|
|
name: "Valid Config",
|
|
payload: []byte(`{"apiKey":"sk_test","endpoint":"https://api.column.com"}`),
|
|
expected: Config{
|
|
APIKey: "sk_test",
|
|
Endpoint: "https://api.column.com",
|
|
PollingPeriod: defaultPollingPeriod,
|
|
},
|
|
expectError: false,
|
|
},
|
|
{
|
|
name: "Missing Required Fields",
|
|
payload: []byte(`{"apiKey":"sk_test"}`),
|
|
expected: Config{},
|
|
expectError: true,
|
|
},
|
|
{
|
|
name: "Non default polling period",
|
|
payload: []byte(`{"apiKey":"sk_test","endpoint":"https://api.column.com","pollingPeriod":"45m"}`),
|
|
expected: Config{
|
|
APIKey: "sk_test",
|
|
Endpoint: "https://api.column.com",
|
|
PollingPeriod: longPollingPeriod,
|
|
},
|
|
expectError: false,
|
|
},
|
|
{
|
|
name: "Invalid polling period",
|
|
payload: []byte(`{"apiKey":"sk_test","endpoint":"https://api.column.com","pollingPeriod":"not-a-duration"}`),
|
|
expected: Config{},
|
|
expectError: true,
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
config, err := unmarshalAndValidateConfig(tt.payload)
|
|
if tt.expectError {
|
|
require.Error(t, err)
|
|
} else {
|
|
require.NoError(t, err)
|
|
assert.Equal(t, tt.expected, config)
|
|
}
|
|
})
|
|
}
|
|
}
|