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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃敟 Challenge: Migration tests recipe #58

Open
goldbergyoni opened this issue Jan 17, 2021 · 0 comments
Open

馃敟 Challenge: Migration tests recipe #58

goldbergyoni opened this issue Jan 17, 2021 · 0 comments

Comments

@goldbergyoni
Copy link
Contributor

Intergation tests are powerful becuase they allow testing the dark parts of the engine. Migrations are one of the darkest corners.

Two proposed tests:

  • Undo all migrations without failures - This proves that we can undo. But it doesn't promise anything about the logic
  • Ensure that migration is logically correct - Assuming that in v0.1 the field order.hasSupportTickets is optional and for some records it is null. Then in v0.2 this field is mandatory + New logic is presented: If this field is true, an order can not be deleted. The migration should set all NULL fields to true. A Typical test will insert records where this field is set (not null), it not even possible to insert an empty hasSupportTickets column because v0.2 doesn't allow this. But, in production for some rows it's null as they were inserted previously!

We can test this with:

test('When older Order record exist with empty hasSupportTickets and trying to delete it, then deletion fails with HTTP 409', () => {

// Arrange

migrate the DB to v0.1
insert an order with empty hasSupportTickets
migrate the DB to v0.2

// Act
try to delete the order

// Assert
...
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant