Skip to content
This repository has been archived by the owner on Jun 15, 2022. It is now read-only.

Risky test for CLITest::test_migrate_output_when_items_were_skipped() #83

Closed
stevegrunwell opened this issue Sep 24, 2018 · 0 comments
Closed

Comments

@stevegrunwell
Copy link
Contributor

During CI, we're often running into the following failure:

  1. CLITest::test_migrate_output_when_items_were_skipped
    Expected to only see two orders in the custom table.
    Failed asserting that 1 matches expected 2.
    /home/travis/build/liquidweb/woocommerce-custom-orders-table/tests/test-cli.php:267

Unfortunately, we're only seeing the issue occasionally — re-running the CI job often enables the test to pass. That means this test may be behaving improperly, which needs adjusted.

@stevegrunwell stevegrunwell added this to the Version 1.0.0 milestone Sep 24, 2018
@stevegrunwell stevegrunwell self-assigned this Sep 24, 2018
stevegrunwell added a commit that referenced this issue Sep 24, 2018
When a test creates multiple test orders within the same second, the resulting products cause MySQL to try to guess which order should come first rather than — as I had assumed — falling back to sorting by ID. As a result, ordering products by p.post_date alone cannot reliably keep two orders sorted the same way, since MySQL may decide to give precedence to any one of the rows with matching timestamps. Further details are [available in MySQL's "ORDER BY Optimization" documentation](https://dev.mysql.com/doc/refman/5.5/en/order-by-optimization.html).

This commit ensures that the `migrate` command explicitly falls back to sorting by `wp_posts.ID` in descending order, which matches the intent of "migrate the most recent orders (which are presumably more likely to be active) first, working backwards historically".

Additionally, this commit cleans up instances where tests were passing integers instead of arrays to `TestCase::count_orders_in_table_with_ids()`, relying on type coercion.

Fixes #83.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant