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

Add Support for Order-Agnostic "expected-output" Array Comparison #38

Open
jpglencross opened this issue Nov 27, 2024 · 3 comments
Open

Comments

@jpglencross
Copy link

jpglencross commented Nov 27, 2024

Currently, the compareOutput() function compares arrays strictly by order.

But in our case, the order of the results isn't important, just the array entries. If possible, it'd be great to add another key to the meta file to flag whether the test should be run in an order-agnostic-test-comparison or not.

Example where it's currently failing:

const inputArray = [1, { a: 2 }, [3, 4]];
const expectedOutcome = [[3, 4], { a: 2 }, 1];

// --- 
// Current behavior
isEqual(inputArray, expectedOutcome); // false

// --- 
// Desired behaviour - with order-agnostic comparison 
const orderAgnosticTestComparison =
      transformationDict[transformerVersionID]["order-agnostic-test-comparison"];

if (orderAgnosticTestComparison) {
  isEqual(inputArray.sort(), expectedOutcome.sort()); // true
} else {
  isEqual(inputArray, expectedOutcome); // false
}
@jpglencross
Copy link
Author

@RitikMani @sivashanmukh @sayan-mitra @Jayachand - sorry for the @'s but you seem to be the top contributors

Not sure on the flow for approvals here, but I'm happy to do the PR for these changes, but wanting to get people's thoughts on it before doing so. Please let me know, thank you!

@abhimanyubabbar
Copy link
Contributor

Hey @jpglencross can you expand on the requirements a bit more ?

@jpglencross
Copy link
Author

jpglencross commented Dec 11, 2024

Hi there @abhimanyubabbar,

The use case here is around an issue facing issues where our migrations that use external APIs as part of the migration, aren't always completed in the order that they start in.

That's why a less strict check on the expected results vs outcome, ignoring order would be useful for us. Does that make sense?

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

No branches or pull requests

2 participants