Skip to content

Commit baa1879

Browse files
committed
fix(aws-marketplace): meter what changed in the books per billing period, so in-place cost top-ups, renewals and cancellations bill exactly
1 parent 24c832a commit baa1879

9 files changed

Lines changed: 559 additions & 270 deletions

File tree

‎apps/sim/lib/billing/aws-marketplace/lifecycle.integration.ts‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,10 +1479,20 @@ describe('license events across listings', () => {
14791479

14801480
expect(await reconcileAwsMarketplaceLicenses()).toMatchObject({ applied: 1, discarded: 0 })
14811481
expect(deleted).toEqual(['r-0'])
1482-
expect(await readLicense(licenseArn)).toMatchObject({
1483-
status: 'inactive',
1484-
dimension: 'platform',
1485-
})
1482+
const lapsed = await readLicense(licenseArn)
1483+
expect(lapsed).toMatchObject({ status: 'inactive', dimension: 'platform' })
1484+
expect(lapsed?.endedAt).toBeInstanceOf(Date)
1485+
1486+
deliverOnce([licenseUpdated(licenseArn, undefined, undefined, USAGE_PRODUCT)])
1487+
await reconcileAwsMarketplaceLicenses()
1488+
expect((await readLicense(licenseArn))?.endedAt).toEqual(lapsed?.endedAt)
1489+
1490+
entitlementsByLicense.set(licenseArn, [
1491+
currentEntitlement({ ProductCode: USAGE_PRODUCT, Dimension: 'platform' }),
1492+
])
1493+
deliverOnce([licenseUpdated(licenseArn, undefined, undefined, USAGE_PRODUCT)])
1494+
await reconcileAwsMarketplaceLicenses()
1495+
expect(await readLicense(licenseArn)).toMatchObject({ status: 'active', endedAt: null })
14861496
})
14871497
})
14881498

‎apps/sim/lib/billing/aws-marketplace/metering.integration.ts‎

Lines changed: 168 additions & 85 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)