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

Run E2E tests also using MySQL #252

Merged
merged 3 commits into from
Aug 9, 2023
Merged

Run E2E tests also using MySQL #252

merged 3 commits into from
Aug 9, 2023

Conversation

josecelano
Copy link
Member

E2E tests are only executed with SQLite.

@josecelano josecelano linked an issue Aug 9, 2023 that may be closed by this pull request
@josecelano josecelano changed the title Run E2E with MySQL too Run E2E tests also using MySQL Aug 9, 2023
@josecelano
Copy link
Member Author

josecelano commented Aug 9, 2023

With this first version, we can run the E2E tests with MySQL. I have to refactor the code to remove duplication; it's just the first iteration.

On the other hand, one test is failing with MySQL:

---- e2e::web::api::v1::contexts::category::contract::it_should_not_allow_adding_duplicated_categories stdout ----
Loading configuration from config file `./config-idx-back.mysql.local.toml`
thread 'e2e::web::api::v1::contexts::category::contract::it_should_not_allow_adding_duplicated_categories' panicked at tests/e2e/web/api/v1/contexts/category/contract.rs:145:5:
assertion failed: `(left == right)`
  left: `500`,
 right: `400`
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

It does not allow to add duplicate categories, but the MySQL version returns a 500 instead of a 400.

E2E tests are only executed with SQLite.
…y in MySQL

Using MySQL the endpoint to inser categories returns a different HTTP
status code. It should return a 400 and It was returning a 500.

The reason is we parse the error message and for MySQL the error message
is not the same as SQLite:

MySQL:

```
Error: Duplicate entry 'category name 118802' for key 'torrust_categories.name'
```

It has been changed but we should now rely on concrete error messages.
Besides we should not relay on the database contrains, mahybe we should
check in the handler that the category does not exist.
@josecelano josecelano marked this pull request as ready for review August 9, 2023 17:49
@josecelano josecelano merged commit 4d6ab95 into torrust:develop Aug 9, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Run E2E tests also using MySQL
1 participant