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

Test suite #65

Merged
merged 40 commits into from
Dec 27, 2021
Merged

Test suite #65

merged 40 commits into from
Dec 27, 2021

Conversation

thesoftwarephilosopher
Copy link
Contributor

@thesoftwarephilosopher thesoftwarephilosopher commented Dec 23, 2021

This builds on #62 and (potentially) finishes #23 to add integration tests.

After this PR, scenarios in deal-generator.txt will have IDs like W1siMjQ1NDgyMiIsW11dXQ==.

Using these IDs, we can generate tests like this:

$ npm run generate-test -- W1siMjQ1NDgyMiIsW11dXQ==

Which will print something like this, suitable for pasting into the test suite:

it(`describe test`, () => {
  const { events, actions } = runDealGenerator({
    group: [['L2169473', []], ['2479625', ['AT-131949332[2479625]', 'AT-97165138[2479625]']]],
    records: [
      testLicense("L2169473", "2013-01-21", "EVALUATION", "inactive"),
      testLicense("2479625", "2013-01-23", "COMMERCIAL", "active"),
      testTransaction("2479625", "2020-04-07", "COMMERCIAL", "Upgrade", "AT-97165138", 411),
      testTransaction("2479625", "2021-03-25", "COMMERCIAL", "Renewal", "AT-131949332", 274)
    ],
  });
  expect(events).toEqual([
    ['purchase', 'L2169473', '2479625'],
    ['upgrade', 'AT-97165138[2479625]'],
    ['renewal', 'AT-131949332[2479625]']
  ]);
  expect(actions).toEqual([
    {
      Create: {
        dealStage: 'CLOSED_WON',
        addonLicenseId: '2479625',
        transactionId: null,
        closeDate: '2013-01-23',
        amount: 0
      }
    },
    {
      Create: {
        dealStage: 'CLOSED_WON',
        addonLicenseId: '2479625',
        transactionId: 'AT-97165138',
        closeDate: '2020-04-07',
        amount: 411
      }
    },
    {
      Create: {
        dealStage: 'CLOSED_WON',
        addonLicenseId: '2479625',
        transactionId: 'AT-131949332',
        closeDate: '2021-03-25',
        amount: 274
      }
    }
  ]);
});

This only tests the deal-generation phase of the engine. But it is one of the most vital and complex parts of the engine, which is why this task focused on that. The only other big part of the engine we could test is the license matcher. That has so far only been tested with a combination of trial and error, and saving extreme amounts of logs, but it has been very thoroughly tested. It will be much harder to test on fake data than the deal generator, but it's probably still possible if/when we want to add tests for it.

@thesoftwarephilosopher thesoftwarephilosopher linked an issue Dec 23, 2021 that may be closed by this pull request
5 tasks
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.

Add integration tests
3 participants