Files
fgueryandGitHub e38985e674 feat(EN-208): set a different polling interval per plugin where appropriate (#572)
* 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
2025-11-04 09:22:42 +00:00

34 lines
975 B
Go

package sharedconfig_test
import (
"testing"
"time"
"github.com/formancehq/payments/internal/connectors/plugins/sharedconfig"
)
func TestParsePollingPeriod(t *testing.T) {
cases := []struct {
raw string
def, min, want time.Duration
wantErr bool
}{
{"", 30 * time.Minute, 20 * time.Minute, 30 * time.Minute, false},
{"15m", 30 * time.Minute, 20 * time.Minute, 20 * time.Minute, false},
{"45m", 30 * time.Minute, 20 * time.Minute, 45 * time.Minute, false},
{"not-a-duration", 30 * time.Minute, 20 * time.Minute, 0, true},
}
for _, c := range cases {
got, err := sharedconfig.NewPollingPeriod(c.raw, c.def, c.min)
if c.wantErr && err == nil {
t.Fatalf("expected error for value %s", c.raw)
}
if !c.wantErr && err != nil {
t.Fatalf("unexpected error for value %s: %v", c.raw, err)
}
if !c.wantErr && got.Duration() != c.want {
t.Fatalf("unexpected result for value %s, got %v, want %v", c.raw, got, c.want)
}
}
}