-
Notifications
You must be signed in to change notification settings - Fork 10
feat(EN-208): set a different polling interval per plugin where appropriate #572
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
77d6112
feat(EN-208): enable default & minimum polling period specifically fo…
fguery 28d1db5
feat(EN-208): update openAPI + fix compile-configs tool to support Du…
fguery 0000b74
feat(EN-208): created helper type for period so it's easier to genera…
fguery e1162ae
feat(EN-208): enable pollingPeriod for atlar
fguery 2fb206e
feat(EN-208): same treatment for bankingbridge
fguery cf2bd7e
feat(EN-208): change column
fguery adcda58
feat(EN-208): added pollingPeriod for generic.
fguery 55b835a
feat(EN-208): increase, couldn't connecto properly
fguery 36be87d
feat(EN-208): added pollingPeriod for mangopay, modulr, moneycorp, qo…
fguery 2b5146e
feat(EN-208): fixed openapi and sdk
fguery 66ce32f
fix: change global default/min pollingPeriod
fguery 88ba09a
fix: e2e tests
fguery File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| package connectors | ||
|
|
||
| import ( | ||
| "encoding/json" | ||
| "testing" | ||
| "time" | ||
|
|
||
| "github.com/formancehq/payments/internal/models" | ||
| "github.com/stretchr/testify/assert" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func TestCombineConfigs_PluginPrecedence(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| base := models.Config{ | ||
| Name: "conn-name", | ||
| PollingPeriod: 10 * time.Minute, // lower than plugin | ||
| PageSize: 50, | ||
| } | ||
|
|
||
| pluginCfg := map[string]any{ | ||
| "apiKey": "sk_test", | ||
| "pollingPeriod": "20m0s", // plugin-normalized value should win | ||
| } | ||
|
|
||
| b, err := combineConfigs(base, pluginCfg) | ||
| require.NoError(t, err) | ||
|
|
||
| var out map[string]any | ||
| require.NoError(t, json.Unmarshal(b, &out)) | ||
|
|
||
| // Plugin value should take precedence | ||
| assert.Equal(t, "20m0s", out["pollingPeriod"]) | ||
|
|
||
| // Base-only fields should be present | ||
| assert.Equal(t, "conn-name", out["name"]) | ||
| // pageSize from base since plugin didn't set it | ||
| assert.Equal(t, float64(50), out["pageSize"]) // numbers become float64 via json | ||
|
|
||
| // Plugin specific field preserved | ||
| assert.Equal(t, "sk_test", out["apiKey"]) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| package atlar | ||
|
|
||
| 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(`{"baseUrl":"https://api.atlar.com","accessKey":"ak_test","secret":"sk_test"}`), | ||
| expected: Config{ | ||
| BaseURL: "https://api.atlar.com", | ||
| AccessKey: "ak_test", | ||
| Secret: "sk_test", | ||
| PollingPeriod: defaultPollingPeriod, | ||
| }, | ||
| expectError: false, | ||
| }, | ||
| { | ||
| name: "Missing Required Fields", | ||
| payload: []byte(`{"baseUrl":"https://api.atlar.com"}`), | ||
| expected: Config{}, | ||
| expectError: true, | ||
| }, | ||
| { | ||
| name: "Non default polling period", | ||
| payload: []byte(`{"baseUrl":"https://api.atlar.com","accessKey":"ak_test","secret":"sk_test","pollingPeriod":"45m"}`), | ||
| expected: Config{ | ||
| BaseURL: "https://api.atlar.com", | ||
| AccessKey: "ak_test", | ||
| Secret: "sk_test", | ||
| PollingPeriod: longPollingPeriod, | ||
| }, | ||
| expectError: false, | ||
| }, | ||
| { | ||
| name: "Invalid polling period", | ||
| payload: []byte(`{"baseUrl":"https://api.atlar.com","accessKey":"ak_test","secret":"sk_test","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) | ||
| } | ||
| }) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this change is annoying, but fixing it seems quite challenging. LMK if I should look more into it.