Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-66506

Create a new assert.eq helper that assigns meaning to its operands

    • Query Execution
    • Fully Compatible
    • QE 2022-09-19, QE 2022-10-03, QE 2022-10-17, QE 2022-10-31, QE 2022-11-14, QE 2022-11-28, QE 2022-12-12, QE 2022-12-26, QE 2023-01-09, QE 2023-01-23

      Create a new assert.eq() operator that assigns meanings to its operands – for example, explicitly making one argument expected and the other argument actual. This would allow for us to make better, more readable error messages when the assertions actually fail.

      One way to migrate the code from the old assert.eq() to the new one:

      1. Rename the existing function assert.eq_deprecated(), and replace all existing usages via sed.
      2. Create a new assert.eq() with the desired semantics and start using it in new code.
      3. Create tickets to migrate older code to use the newer version
      Original Description

      Currently, the signature is just function (a, b, msg) and the message in case of failure is just "[1] != [0] are not equal" and you have to look into the test to understand if 1 is expected or if 0 is expected.

      I suggest to change the signature to function(expected, actual, msg) and change the default message to "expected value [1] and actual value [0] are not equal". Of course, many tests still use those interchangeably, but we can write the new tests following this semantics and "fix" the existing tests over time.

        There are no Sub-Tasks for this issue.

            Assignee:
            backlog-query-execution [DO NOT USE] Backlog - Query Execution
            Reporter:
            romans.kasperovics@mongodb.com Romans Kasperovics
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated: