Skip to content

feat(events): add task updated events #457

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 2 commits into from
May 26, 2025
Merged

feat(events): add task updated events #457

merged 2 commits into from
May 26, 2025

Conversation

paul-nicolas
Copy link
Contributor

Description

This PR does two things:

  • Add events when a task is updated
  • Fix temporal workflow tests when the error wanted is not what we had

Context

Tasks

When a user creates something via the API (bank accounts, payouts, transfers...), he currently has to poll the api to get the object id when the task is updated which is a bit of a pain.

Tests

When testing temporal workflows, sometimes we test that the workflow returns an error, but we never test what is the error. Some workflows were failing because we missed the mock of a specific functions and the actual error was not catched.

Solution

Tasks

This PR adds a new event for tasks, that the user can listen through nats/webhooks in order to get the created object.

Tests

This PR adds specific errors to catch in the test to be sure that we have the right error

Copy link
Contributor

coderabbitai bot commented May 26, 2025

Walkthrough

This change introduces a new task update event type, adds a Task field to SendEvents, and refactors workflow code to handle task update events. It also updates tests to verify task payloads and error messages.

Changes

File(s) Change Summary
internal/connectors/engine/activities/activity.go Registers new "EventsSendTaskUpdated" activity in the activities definition set.
internal/connectors/engine/activities/events_send_task_updated.go Adds activity and workflow functions for sending updated task events.
internal/events/task.go Introduces event message creation for updated task events.
internal/models/tasks.go Adds IdempotencyKey() method to Task struct.
pkg/events/event.go Defines new event type constant: EventTypeUpdatedTask.
internal/connectors/engine/workflow/send_events.go Adds Task *models.Task to SendEvents; updates logic to handle and dispatch task update events.
internal/connectors/engine/workflow/update_tasks.go Refactors with new updateTask helper to handle storing and sending task events.
internal/connectors/engine/workflow/send_events_test.go Adds/updates tests for task events and standardizes error handling in event-related tests.
internal/connectors/engine/workflow/create_bank_account_test.go, ... (many other *_test.go files) Updates tests to assert on new Task field, standardizes error messages, and validates event sending for tasks.
internal/connectors/plugins/public/atlar/bank_account_creation_test.go Updates error message in test to "error-test".

Sequence Diagram(s)

sequenceDiagram
    participant Workflow
    participant Activities
    participant Events
    participant Publish

    Workflow->>Activities: StorageTasksStore(task)
    Activities-->>Workflow: Store result
    Workflow->>Activities: EventsSendTaskUpdated(task)
    Activities->>Events: NewEventUpdatedTask(task)
    Events->>Publish: Publish EventMessage (UPDATED_TASK)
    Publish-->>Events: Publish result
    Activities-->>Workflow: Send event result
Loading

Possibly related PRs

  • formancehq/payments#393: Focuses on cleaning up event payloads and JSON tags, related through event structure and handling.
  • formancehq/payments#390: Adds new event types and functions for payment initiation events, related to event handling and definitions.
  • formancehq/payments#394: Adds support for v2 event types and structures, related through evolving event version support.

Poem

A bunny hops with nimble feet,
New tasks to send, a change so sweet!
Now events for tasks can fly,
With idempotency, oh my!
Through workflows, tests, and code so neat—
This update makes our system fleet!
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ba9a044 and 45fac0a.

📒 Files selected for processing (1)
  • internal/connectors/engine/workflow/send_events_test.go (25 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Tests
🔇 Additional comments (5)
internal/connectors/engine/workflow/send_events_test.go (5)

32-37: LGTM! Well-structured task test data.

The task object is properly initialized with all required fields, following the same pattern as other test data objects in the file.


119-119: Good improvement to error message specificity.

The change from "test" to "error-test" makes the error messages more descriptive and easier to identify in test outputs.

Also applies to: 128-128


186-203: LGTM! Well-implemented task success test.

The test function follows the established pattern for success scenarios and properly validates the task event sending workflow.


225-244: LGTM! Comprehensive task error test.

The test function correctly validates error handling in the task event sending workflow, maintaining consistency with other error test patterns.


139-139: Consistent error message improvements throughout the file.

All error message changes from "test" to "error-test" have been applied consistently across all test functions. This standardization improves test debugging and error identification.

Also applies to: 149-149, 211-213, 222-222, 272-274, 283-283, 308-310, 319-319, 411-413, 422-422, 441-443, 452-452, 479-481, 490-490, 515-517, 526-526, 555-557, 566-566, 593-595, 604-604, 631-633, 642-642

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@paul-nicolas paul-nicolas marked this pull request as ready for review May 26, 2025 08:41
@paul-nicolas paul-nicolas requested a review from a team as a code owner May 26, 2025 08:41
Copy link

codecov bot commented May 26, 2025

Codecov Report

Attention: Patch coverage is 85.39326% with 13 lines in your changes missing coverage. Please review.

Project coverage is 69.10%. Comparing base (43a2a1d) to head (45fac0a).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
internal/connectors/engine/activities/activity.go 0.00% 4 Missing ⚠️
...tors/engine/activities/events_send_task_updated.go 0.00% 4 Missing ⚠️
...nternal/connectors/engine/workflow/update_tasks.go 93.18% 2 Missing and 1 partial ⚠️
internal/models/tasks.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #457   +/-   ##
=======================================
  Coverage   69.09%   69.10%           
=======================================
  Files         599      601    +2     
  Lines       30534    30605   +71     
=======================================
+ Hits        21098    21150   +52     
- Misses       8323     8339   +16     
- Partials     1113     1116    +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

♻️ Duplicate comments (2)
internal/connectors/engine/workflow/create_transfer_test.go (1)

183-194: Consistent implementation of task update event validation.

internal/connectors/engine/workflow/fetch_accounts_test.go (1)

189-206: Error message standardization.

🧹 Nitpick comments (3)
internal/connectors/engine/workflow/handle_webhooks_test.go (1)

11-11: Remove unused import.

The go.temporal.io/sdk/workflow import is not used in this test file.

-	"go.temporal.io/sdk/workflow"
internal/events/task.go (1)

22-53: Consider simplifying the inline functions for better readability.

The implementation is correct and follows good practices. However, the inline functions could be simplified.

Consider this more concise approach:

 func (e Events) NewEventUpdatedTask(task models.Task) publish.EventMessage {
+	var connectorID *string
+	if task.ConnectorID != nil {
+		connectorID = pointer.For(task.ConnectorID.String())
+	}
+	
+	var errorMsg *string
+	if task.Error != nil {
+		errorMsg = pointer.For(task.Error.Error())
+	}
+
 	payload := taskMessagePayload{
 		ID: task.ID.String(),
-		ConnectorID: func() *string {
-			if task.ConnectorID == nil {
-				return nil
-			}
-
-			return pointer.For(task.ConnectorID.String())
-		}(),
+		ConnectorID:     connectorID,
 		Status:          string(task.Status),
 		CreatedAt:       task.CreatedAt,
 		UpdatedAt:       task.UpdatedAt,
 		CreatedObjectID: task.CreatedObjectID,
-		Error: func() *string {
-			if task.Error == nil {
-				return nil
-			}
-
-			return pointer.For(task.Error.Error())
-		}(),
+		Error:           errorMsg,
 	}
internal/connectors/engine/activities/events_send_task_updated.go (1)

10-18: Add test coverage for the new activity.

The implementation follows the established pattern for event activities. However, static analysis indicates that these lines lack test coverage.

Would you like me to generate test cases for this new activity to improve coverage?

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 10-11: internal/connectors/engine/activities/events_send_task_updated.go#L10-L11
Added lines #L10 - L11 were not covered by tests


[warning] 16-17: internal/connectors/engine/activities/events_send_task_updated.go#L16-L17
Added lines #L16 - L17 were not covered by tests

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 43a2a1d and facb71b.

📒 Files selected for processing (30)
  • internal/connectors/engine/activities/activity.go (1 hunks)
  • internal/connectors/engine/activities/events_send_task_updated.go (1 hunks)
  • internal/connectors/engine/workflow/create_bank_account_test.go (10 hunks)
  • internal/connectors/engine/workflow/create_payout_test.go (20 hunks)
  • internal/connectors/engine/workflow/create_transfer_test.go (20 hunks)
  • internal/connectors/engine/workflow/create_webhooks_test.go (6 hunks)
  • internal/connectors/engine/workflow/fetch_accounts_test.go (15 hunks)
  • internal/connectors/engine/workflow/fetch_balances_test.go (15 hunks)
  • internal/connectors/engine/workflow/fetch_external_accounts_test.go (15 hunks)
  • internal/connectors/engine/workflow/fetch_others_test.go (11 hunks)
  • internal/connectors/engine/workflow/fetch_payments_test.go (24 hunks)
  • internal/connectors/engine/workflow/handle_webhooks_test.go (10 hunks)
  • internal/connectors/engine/workflow/install_connector_test.go (6 hunks)
  • internal/connectors/engine/workflow/plugin_workflow_test.go (6 hunks)
  • internal/connectors/engine/workflow/poll_payout_test.go (12 hunks)
  • internal/connectors/engine/workflow/poll_transfer_test.go (12 hunks)
  • internal/connectors/engine/workflow/reset_connector_test.go (15 hunks)
  • internal/connectors/engine/workflow/reverse_payout_test.go (36 hunks)
  • internal/connectors/engine/workflow/reverse_transfer_test.go (36 hunks)
  • internal/connectors/engine/workflow/send_events.go (2 hunks)
  • internal/connectors/engine/workflow/send_events_test.go (25 hunks)
  • internal/connectors/engine/workflow/terminate_schedules_test.go (3 hunks)
  • internal/connectors/engine/workflow/terminate_workflows_test.go (4 hunks)
  • internal/connectors/engine/workflow/uninstall_connector_test.go (32 hunks)
  • internal/connectors/engine/workflow/update_payment_initiation_from_payment_test.go (4 hunks)
  • internal/connectors/engine/workflow/update_tasks.go (2 hunks)
  • internal/connectors/plugins/public/atlar/bank_account_creation_test.go (1 hunks)
  • internal/events/task.go (1 hunks)
  • internal/models/tasks.go (1 hunks)
  • pkg/events/event.go (1 hunks)
🧰 Additional context used
🪛 GitHub Check: codecov/patch
internal/connectors/engine/workflow/update_tasks.go

[warning] 72-73: internal/connectors/engine/workflow/update_tasks.go#L72-L73
Added lines #L72 - L73 were not covered by tests

internal/models/tasks.go

[warning] 35-36: internal/models/tasks.go#L35-L36
Added lines #L35 - L36 were not covered by tests

internal/connectors/engine/workflow/send_events.go

[warning] 221-222: internal/connectors/engine/workflow/send_events.go#L221-L222
Added lines #L221 - L222 were not covered by tests

internal/connectors/engine/activities/activity.go

[warning] 330-333: internal/connectors/engine/activities/activity.go#L330-L333
Added lines #L330 - L333 were not covered by tests

internal/connectors/engine/activities/events_send_task_updated.go

[warning] 10-11: internal/connectors/engine/activities/events_send_task_updated.go#L10-L11
Added lines #L10 - L11 were not covered by tests


[warning] 16-17: internal/connectors/engine/activities/events_send_task_updated.go#L16-L17
Added lines #L16 - L17 were not covered by tests

🔇 Additional comments (55)
internal/connectors/plugins/public/atlar/bank_account_creation_test.go (1)

104-108: LGTM! Test error message standardization.

The error message change from "test-error" to "error-test" aligns with the standardization across other test files in the codebase, improving consistency.

internal/connectors/engine/workflow/terminate_workflows_test.go (2)

86-96: LGTM! Improved error verification in workflow tests.

The standardization to "error-test" ensures consistent error message verification across temporal workflow tests, aligning with the PR objective to improve test accuracy.


115-125: LGTM! Consistent error handling in termination test.

The error message standardization maintains consistency with the previous test case, ensuring uniform error verification across the test suite.

internal/connectors/engine/workflow/terminate_schedules_test.go (2)

100-111: LGTM! Consistent error message standardization.

The error message updates to "error-test" maintain consistency with the standardization pattern across other workflow test files.


130-130: LGTM! Error standardization in schedule deletion test.

The change aligns with the project-wide test error message standardization.

pkg/events/event.go (1)

19-19: LGTM: New event type constant follows established patterns.

The addition of EventTypeUpdatedTask is consistent with existing naming conventions and properly positioned in the constants list.

internal/connectors/engine/activities/activity.go (1)

330-333: LGTM: Activity definition follows established patterns.

The new EventsSendTaskUpdated activity definition is properly structured and follows the existing pattern. However, static analysis indicates these lines lack test coverage.

Consider adding test coverage for the new activity definition to ensure it's properly registered and functional.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 330-333: internal/connectors/engine/activities/activity.go#L330-L333
Added lines #L330 - L333 were not covered by tests

internal/connectors/engine/workflow/update_payment_initiation_from_payment_test.go (4)

65-65: LGTM: Standardizing error messages for test reliability.

Good improvement to use consistent error messages across the test suite.


75-75: LGTM: Consistent error message standardization.

The error assertion correctly matches the updated error message format.


84-84: LGTM: Error message consistency maintained.

The temporal error creation uses the standardized message format.


94-94: LGTM: Error assertion matches standardized format.

The error containment check properly validates the standardized error message.

internal/connectors/engine/workflow/create_webhooks_test.go (6)

52-52: LGTM: Standardized error message format.

Good improvement to use consistent error messages across test scenarios.


64-64: LGTM: Error assertion matches standardized format.

The error containment check properly validates the updated error message.


83-83: LGTM: Consistent temporal error creation.

The storage activity error uses the standardized message format.


95-95: LGTM: Error assertion consistency maintained.

The error validation correctly checks for the standardized message.


113-113: LGTM: Workflow error standardization.

The workflow error creation follows the consistent message format.


125-125: LGTM: Final error assertion standardized.

The error containment check completes the consistent error handling pattern.

internal/connectors/engine/workflow/create_transfer_test.go (3)

79-90: LGTM! Correctly validates task update event dispatch.

The mock properly verifies that after successful task completion, a SendEvents request is made with only the Task field populated, ensuring task update events are sent to subscribers.


259-282: Good error handling pattern.

The changes correctly ensure that task update events are sent even in failure scenarios, and the standardized error message improves test consistency.


570-593: Valid edge case test for storage failure.

This test correctly handles the scenario where the task storage operation itself fails, which is distinct from storing a task with failed status. The implementation is appropriate for this edge case.

internal/connectors/engine/workflow/fetch_accounts_test.go (1)

235-236: Good practice: Explicit error presence check.

Adding s.Error(err) before s.ErrorContains() ensures the error exists before checking its content, preventing potential nil pointer issues.

internal/connectors/engine/workflow/fetch_balances_test.go (2)

188-191: Clean error handling pattern.

Using expectedErr variables improves code readability and makes error reuse cleaner than inline creation.


499-503: Proper Temporal error wrapping.

Correctly wraps errors with temporal.NewNonRetryableApplicationError to ensure proper error propagation through the workflow system.

internal/connectors/engine/workflow/poll_payout_test.go (3)

59-70: LGTM! Proper task event verification added.

The test correctly verifies that task update events are sent after successful payout polling, with appropriate field validation.


116-139: LGTM! Consistent error handling and event verification.

The changes properly standardize the error message format and ensure task update events are sent even in error scenarios.


168-171: Consistent test improvements across all error scenarios.

All error test cases now follow a standardized pattern with:

  • Consistent "error-test" error messages
  • Proper task event verification via RunSendEvents mocks
  • Appropriate error assertions

This improves test maintainability and ensures task events are properly sent in all scenarios.

Also applies to: 197-207, 239-249, 276-286, 315-325, 363-366, 405-408, 443-460

internal/connectors/engine/workflow/fetch_others_test.go (1)

170-172: Excellent test standardization and error validation improvements.

The changes consistently:

  • Standardize all error messages to "error-test" for better test maintainability
  • Add explicit s.Error(err) assertions before ErrorContains checks, ensuring errors are actually present
  • Use proper error construction with temporal.NewNonRetryableApplicationError

These improvements enhance test reliability and consistency across the test suite.

Also applies to: 188-188, 194-197, 218-218, 235-238, 259-259, 283-285, 306-306, 331-333, 354-354, 380-384, 400-400

internal/connectors/engine/workflow/plugin_workflow_test.go (1)

349-349: Consistent error message standardization.

All error messages have been standardized to "error-test", maintaining consistency with the test suite improvements across other files.

Also applies to: 373-373, 382-382, 406-406, 416-416, 440-440

internal/connectors/engine/workflow/create_payout_test.go (2)

79-90: LGTM! Task event propagation properly tested.

The test correctly verifies that the Task object is propagated through the SendEvents workflow after successful payout creation.


256-282: LGTM! Error handling and task propagation properly tested.

The test correctly:

  1. Standardizes the error message to "error-test"
  2. Verifies that Task events are sent even in failure scenarios
  3. Adds proper error assertion with ErrorContains

This ensures task status updates are sent regardless of workflow outcome.

internal/connectors/engine/workflow/fetch_external_accounts_test.go (1)

187-208: LGTM! Enhanced error verification in tests.

The test improvements:

  1. Standardize error messages to "error-test" for consistency
  2. Add explicit error presence verification with s.Error(err) before checking error content

This two-step verification ensures tests fail fast if no error is returned when one is expected.

internal/connectors/engine/workflow/reset_connector_test.go (2)

45-48: LGTM! Task event propagation verified in successful reset.

The test correctly verifies that Task objects are propagated through the SendEvents workflow after successful connector reset.


99-123: LGTM! Comprehensive task event handling in error scenarios.

The test properly verifies that:

  1. Task status is set to FAILED when operations fail
  2. Task update events are sent even in failure scenarios
  3. Error messages are properly propagated and verified

This ensures users receive task update notifications regardless of operation outcome.

internal/connectors/engine/workflow/handle_webhooks_test.go (1)

156-156: LGTM! Error message standardization improves test consistency.

The consistent use of "error-test" across all test error scenarios makes it easier to identify and debug test-specific errors.

Also applies to: 178-178, 194-194, 216-216, 232-232, 254-254, 271-271, 293-293, 321-321, 343-343

internal/connectors/engine/workflow/uninstall_connector_test.go (2)

11-11: LGTM! Workflow import and task event handling added correctly.

The workflow import is properly used in the new RunSendEvents mocks, and the assertion that req.Task is not nil ensures task update events are properly propagated.

Also applies to: 63-66


89-92: LGTM! Consistent task event handling across all test scenarios.

The RunSendEvents workflow is consistently mocked across all test cases, ensuring task update events are sent regardless of success or failure outcomes. This aligns perfectly with the PR objectives of adding task updated events.

Also applies to: 117-120, 147-150, 178-181, 210-213, 243-246, 277-280, 312-315, 348-351, 385-388, 423-426, 462-465, 502-505, 543-546, 585-588

internal/connectors/engine/workflow/install_connector_test.go (1)

59-59: LGTM! Error message standardization applied correctly.

The error messages have been consistently updated to "error-test" across all test cases, maintaining the pattern established in other test files.

Also applies to: 71-71, 80-80, 92-92, 99-104, 114-114, 123-123

internal/events/task.go (1)

12-20: LGTM! Well-structured event payload.

The taskMessagePayload struct is properly designed with appropriate use of pointer types for optional fields.

internal/connectors/engine/workflow/send_events.go (1)

26-26: LGTM! Struct field addition is consistent.

The addition of the Task field follows the existing pattern for other event types.

internal/connectors/engine/workflow/create_bank_account_test.go (2)

48-58: LGTM! Test properly validates task event sending.

The additional mock correctly verifies that a task event is sent after the main operation completes successfully.


73-221: Well-structured test improvements for error scenarios.

The test modifications consistently:

  1. Standardize error messages to "error-test" for better clarity
  2. Verify that task events are sent even in error scenarios
  3. Ensure the Task field is properly populated in SendEvents

These changes improve test maintainability and coverage.

internal/connectors/engine/workflow/reverse_transfer_test.go (1)

115-119: LGTM! Test improvements align with the PR objectives.

The test modifications correctly implement verification for the new task updated events functionality. The consistent pattern of:

  • Adding RunSendEvents workflow calls that verify req.Task is not nil
  • Standardizing error handling with temporal.NewNonRetryableApplicationError("error-test", "error-test", errors.New("error-test"))
  • Adding explicit error assertions with s.ErrorContains(err, "error-test")

ensures that task update events are properly triggered and validated across all test scenarios.

Also applies to: 189-189, 207-210, 224-224, 230-230, 236-239, 253-253, 263-263, 269-272, 286-286, 300-300, 306-309, 323-323, 403-403, 409-412, 426-426, 553-553, 559-562, 576-576, 625-628, 690-690, 696-699, 713-713, 765-765, 771-774, 788-788, 849-849, 855-858, 872-872, 935-935, 941-944, 958-958, 1020-1020, 1027-1030, 1044-1044, 1108-1108, 1114-1117, 1131-1131, 1197-1197, 1203-1206, 1220-1220, 1287-1287, 1302-1302, 1357-1357, 1360-1360, 1366-1369, 1383-1383, 1438-1438, 1442-1442, 1448-1451, 1465-1465

internal/connectors/engine/workflow/fetch_payments_test.go (1)

201-203: LGTM! Consistent error handling improvements in tests.

The error handling standardization across all test functions improves test reliability by:

  • Using consistent "error-test" error messages
  • Properly creating errors with temporal.NewNonRetryableApplicationError
  • Adding explicit s.Error(err) assertions before s.ErrorContains

These changes ensure tests properly validate error scenarios.

Also applies to: 219-219, 225-228, 249-249, 266-269, 290-290, 314-316, 337-337, 362-364, 385-385, 411-413, 434-434, 461-463, 484-484, 512-514, 535-535, 564-568, 584-584, 626-628, 638-638, 670-672, 683-683, 714-716, 726-726, 732-734, 744-744

internal/connectors/engine/workflow/update_tasks.go (2)

13-29: LGTM! Clean refactoring of updateTasksError.

The method now properly constructs a Task object with failed status and delegates to the new updateTask method, eliminating code duplication.


31-46: LGTM! Clean refactoring of updateTaskSuccess.

The method properly constructs a Task object with succeeded status and the created object ID, then delegates to the shared updateTask method.

internal/connectors/engine/workflow/reverse_payout_test.go (2)

115-119: LGTM! Consistent pattern for task update events.

The addition of RunSendEvents workflow mocks with non-nil Task validation is consistently applied across all test functions. This ensures that task update events are properly sent when task statuses are stored.

Also applies to: 207-211, 236-240, 269-273, 306-310, 348-352, 409-413, 490-494, 559-563, 625-629, 696-700, 771-775, 855-859, 941-945, 1026-1030, 1113-1117, 1202-1206, 1365-1369, 1447-1451


189-189: Minor: Consistent error message update.

The error messages have been uniformly changed from "test-error" to "error-test". While this is a minor change, it improves consistency across the test suite.

Also applies to: 224-224, 230-230, 253-253, 263-263, 286-286, 300-300, 323-323, 403-403, 426-426, 553-553, 576-576, 690-690, 713-713, 765-765, 788-788, 849-849, 872-872, 935-935, 958-958, 1020-1020, 1043-1043, 1107-1107, 1130-1130, 1196-1196, 1219-1219, 1286-1286, 1301-1301, 1356-1356, 1359-1359, 1382-1382, 1437-1437, 1441-1441, 1464-1464

internal/connectors/engine/workflow/send_events_test.go (3)

32-38: LGTM! Well-structured task model for testing.

The task variable is properly defined with all necessary fields for testing task update events.


186-204: LGTM! Comprehensive test for task update events.

The test case follows the established pattern and properly validates:

  • Event idempotency key generation
  • Task update activity execution
  • Event storage

This ensures the new task update event functionality works correctly.


119-119: Good improvement: Consistent error handling with temporal errors.

Replacing simple error strings with temporal.NewNonRetryableApplicationError improves error handling consistency and provides better context for workflow failures.

Also applies to: 139-139, 149-149, 212-212, 222-222, 252-252, 262-262, 288-288, 298-298, 391-391, 401-401, 421-421, 431-431, 459-459, 469-469, 495-495, 505-505, 535-535, 545-545, 573-573, 583-583, 611-611, 621-621

internal/connectors/engine/workflow/poll_transfer_test.go (5)

59-70: LGTM! Properly validates task update event publishing.

The mock correctly ensures that when a task is stored with a SUCCEEDED status, the RunSendEvents workflow is triggered with only the Task field populated, which aligns with the PR objective of adding task updated events.


116-138: LGTM! Consistent error handling and event publishing.

The changes correctly:

  1. Standardize the error message to "error-test" for consistency
  2. Add proper validation that task update events are published when a task fails
  3. Ensure only the Task field is populated in the SendEvents request

167-170: LGTM! Task update event properly published on plugin error.

The mock correctly ensures that task update events are published when a task fails due to a plugin error.


362-365: LGTM! Task update events properly published for schedule deletion errors.

Both test functions correctly add the RunSendEvents mock to ensure task update events are published when tasks fail due to schedule deletion errors.

Also applies to: 404-407


442-459: LGTM! Error handling properly updated.

The error string standardization to "error-test" is correctly implemented with matching assertion. No RunSendEvents mock is needed here since the task storage itself fails.

@paul-nicolas paul-nicolas enabled auto-merge May 26, 2025 11:52
@paul-nicolas paul-nicolas added this pull request to the merge queue May 26, 2025
Merged via the queue into main with commit 4448260 May 26, 2025
9 checks passed
@paul-nicolas paul-nicolas deleted the feat/task-events branch May 26, 2025 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants