Skip to content

Add tests for new insert rules consequence (part 2)#1135

Merged
timkimadobe merged 7 commits intoadobe:feature/historical-consequencefrom
timkimadobe:event-history-tests-part2
Apr 30, 2025
Merged

Add tests for new insert rules consequence (part 2)#1135
timkimadobe merged 7 commits intoadobe:feature/historical-consequencefrom
timkimadobe:event-history-tests-part2

Conversation

@timkimadobe
Copy link
Copy Markdown
Contributor

@timkimadobe timkimadobe commented Apr 24, 2025

Description

This PR adds the tests covering the historical event operations insert and insertIfNotExists. At a high level, it validates:

  • Correct consequence format for all properties in the newly handled schema type
  • Event recorded is what was defined in the consequence's content
  • Event recorded is the same as what is dispatched
  • insertIfNotExists correctly does not insert if event already exists or a database error is returned (-1)

Test setup changes

The base test setup for RulesEngineFunctionalTests has been split into a new base class: RulesEngineTestBase, which the new RulesEngineHistoricalTests also uses.

The TestableExtensionRuntime has been updated to support:

  • Capturing the event to be recorded, when passed through recordHistoricalEvent
  • Setting an optional delay for the getHistoricalEvents operation (by default does not apply any delay)

Related Issue

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@timkimadobe timkimadobe force-pushed the event-history-tests-part2 branch 2 times, most recently from 14ad1b5 to b835de3 Compare April 25, 2025 21:12
@timkimadobe timkimadobe force-pushed the event-history-tests-part2 branch from b835de3 to f8c06a3 Compare April 29, 2025 19:02
// Should not be dispatched
XCTAssertEqual(0, mockRuntime.dispatchedEvents.count)
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nit : Can we also add a test case for testSchemaConsequenceInsert_doesNotDispatchOrRecord_whenContentIsEmpty

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This test case does exist, but it's on line 121. I was thinking it could be better to group it with the valid input tests, since the issue is that an empty content results in a hash of 0, rather than the input format itself being invalid. What do you think?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Ah I missed it. Should be fine where it is now too

@timkimadobe timkimadobe merged commit 20d000d into adobe:feature/historical-consequence Apr 30, 2025
17 checks passed
@timkimadobe timkimadobe deleted the event-history-tests-part2 branch April 30, 2025 00:36
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