Skip to content
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

MNT Fix unit test #11442

Merged

Conversation

emteknetnz
Copy link
Member

@emteknetnz emteknetnz commented Oct 23, 2024

Issue silverstripe/.github#320

Fixes a couple of SilverStripe\ORM\Tests\DBReplicaTest::testRoutes tests failing in recipe-core specifically which won't handle unmatched routes.

https://github.com/silverstripe/recipe-core/actions/runs/11468619556/job/31914133643

Copy link
Member

@GuySartorelli GuySartorelli left a comment

Choose a reason for hiding this comment

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

Can you please explain how this is resolving the problem? It looks like in the failed test we expect a replica to be used (even for unmatched routes), but the primary is used instead.

Is this not just masking the problem? Won't unmatched routes still be using the primary?

@emteknetnz
Copy link
Member Author

The test intended it to hit a matched route, but that route was never added to the config.

The test was accidentally passing before because in non recipe-core setups it finds a route, I'm guessing something that leads to an error page? However in recipe-core this does not appear to happen.

All this PR is doing is making the unit test work as intended.

If you think this behavior is wrong, then it should be done as a new card

@GuySartorelli
Copy link
Member

My point is more that it shouldn't matter whether the route is matched or not - it should always be using the replica, shouldn't it?

If so, this PR doesn't fix the test, it makes the test pass when the test is correctly pointing out there's a problem.

@emteknetnz emteknetnz force-pushed the pulls/6/fix-unit-test branch from aa9988d to fb2cf8a Compare October 23, 2024 23:56
@emteknetnz
Copy link
Member Author

Looks like there's no DB calls made at all when doing a simulated GET to a missing route in recipe-core, have made an inline comment about this

Copy link
Member

@GuySartorelli GuySartorelli left a comment

Choose a reason for hiding this comment

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

Awesome, thanks for looking into that.
LGTM.

@GuySartorelli GuySartorelli merged commit c283741 into silverstripe:6 Oct 24, 2024
10 checks passed
@GuySartorelli GuySartorelli deleted the pulls/6/fix-unit-test branch October 24, 2024 00:25
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