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 mongo integration tests #580

Open
wants to merge 20 commits into
base: main
Choose a base branch
from

Conversation

michelaquino
Copy link

@michelaquino michelaquino commented Nov 20, 2023

Description

Add integration test suit for MongoDB

Closes 579

Proposed Changes

This PR introduces an integration test suite for MongoDB. The focus are the files mongo.go, huskydb.go and huskystats.go. These files contains the main functions related to MongoDB connection and queries. An integration test workflow was added on Github Actions.

Two unit tests that were failing were modified as well:

  1. One unit test in the file api/util/api/api_test.go was fixed. The problem was a missing configuration.

  2. Another one in the file api/token/token_test.go was removed, the one with the description "When GetValidHashFunction returns a false boolean". The function GetValidHashFunction isn't called by the function GenerateAccessToken, the one that the unit test is related to.

Testing

To run the integration tests, the Docker need to be running:

$ make test
$ make integration-test-compose-up
$ make integration-test
$ make integration-test-compose-down

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this test? Since this is not testing anything important in the API or Client.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think yes, even though the code is tested by more complex integration test indirectly, because it tests the smallest amount of code that integrates with the database. If in the future someone decides to move this file to another package, the integration tests move together.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use more real data, running in your local, starting some analysis, then use data similar to what you got. If you don't get some cases, I can provide you with other examples.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I'll change the data. If it's not a problem, it would be nice to provide these examples.

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.

Adding Integration Tests for MongoDB
2 participants