Skip to content

Add tests for new insert rules consequence (part 1) v2#1137

Merged
timkimadobe merged 18 commits intoadobe:feature/historical-consequencefrom
timkimadobe:event-history-tests-part1
Apr 29, 2025
Merged

Add tests for new insert rules consequence (part 1) v2#1137
timkimadobe merged 18 commits intoadobe:feature/historical-consequencefrom
timkimadobe:event-history-tests-part1

Conversation

@timkimadobe
Copy link
Copy Markdown
Contributor

Important

This PR is based on the logic fix in (and this diff currently also contains its changes):

Once #1136 is merged, this PR should reflect the actual scope of changes.

Description

This PR adds test cases for:

EventHub's EventHistory related methods

func getHistoricalEvents(_: [EventHistoryRequest], enforceOrder: Bool, handler: @escaping ([EventHistoryResult]) -> Void)
func recordHistoricalEvent(_: Event, handler: ((Bool) -> Void)? = nil)

One big motivation for adding test coverage here was the update to change EventHub's implementation of getHistoricalEvents in PR:

Where there were no test cases validating the behavior of the handler being called or not in the eventHistory is nil case.

Before

eventHistory?.getEvents(requests, enforceOrder: enforceOrder, handler: handler)

After

eventHistory?.getEvents(requests, enforceOrder: enforceOrder, handler: handler) ?? handler([])

Event's new support for conversion to EventHistoryRequest via .toEventHistoryRequest

Tests the conversion of Event into an EventHistoryRequest especially when different event masks are set.

Other changes

New MockEventHistory that provides a mock implementation for the EventHistoryService protocol.

Note

Q: Should this be included in AEPCore public test utils? I thought not because only EventHub uses EventHistoryService and also eventHistory is private on EventHub

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.

… EventHub to use dependency injection for EventHistory

Update MockEventHistoryDatabase to use new EventHistoryDatabaseService protocol
Update EventHistory and EventHistoryDatabase to conform to their respective protocols
Update MockEventHistory to conform to EventHistoryService protocol and fix implementation
Fix EventHubEventHistoryTests to use the instantiated eventhub instance not the shared one

# Conflicts:
#	AEPCore.xcodeproj/project.pbxproj
#	AEPCore/Mocks/PublicTestUtils/MockEventHistoryDatabase.swift
#	AEPCore/Tests/EventHubTests/EventHubEventHistoryTests.swift
#	AEPCore/Tests/TestHelpers/MockEventHistory.swift
Copy link
Copy Markdown
Contributor

@cdhoffmann cdhoffmann left a comment

Choose a reason for hiding this comment

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

LGTM

Update EventHistory init to accommodate this read only access to the backing storage
… EventHub to use dependency injection for EventHistory

Update MockEventHistoryDatabase to use new EventHistoryDatabaseService protocol
Update EventHistory and EventHistoryDatabase to conform to their respective protocols
Update MockEventHistory to conform to EventHistoryService protocol and fix implementation
Fix EventHubEventHistoryTests to use the instantiated eventhub instance not the shared one
@timkimadobe timkimadobe force-pushed the event-history-tests-part1 branch from 41ce3e2 to 1571d75 Compare April 29, 2025 01:22
@timkimadobe timkimadobe merged commit db77c50 into adobe:feature/historical-consequence Apr 29, 2025
17 checks passed
@timkimadobe timkimadobe deleted the event-history-tests-part1 branch April 29, 2025 18:20
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