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

Fix all router endpoint integration tests #36

Merged
merged 3 commits into from
Feb 26, 2024
Merged

Conversation

jhodapp
Copy link
Member

@jhodapp jhodapp commented Feb 26, 2024

Description

This PR fixes all of the broken tests in router.rs that broke when we introduced AuthSession from axum-login and the Organization endpoints being protected behind a valid login session.

GitHub Issue: Fixes #32

Changes

  • Update how the DatabaseConnection instance is shared between AppState and user::Backend (see this Rust documentation for how Arc allows this sharing via clone())
  • Update all tests to log in and establish a valid AuthSession

Testing Strategy

  1. Run cargo test and ensure all tests pass

Concerns

None

@jhodapp jhodapp added the enhancement Improves existing functionality or feature label Feb 26, 2024
@jhodapp jhodapp self-assigned this Feb 26, 2024
@jhodapp jhodapp linked an issue Feb 26, 2024 that may be closed by this pull request

/// Creates a test user::Model entity instance that can be used by tests to
/// log in to the /login endpoint and create a valid AuthSession.
pub fn get_user() -> anyhow::Result<user::Model> {
Copy link
Member Author

Choose a reason for hiding this comment

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

@calebbourg what do you think of this function name get_user()? Do you think it's confusing such that you'd expect some more dynamic getter of a property instead of generating a static instance of a user::Model?

Would create_user() or create_test_user() be better or do you think it's fine as is and I'm just overthinking it?

Copy link
Collaborator

@calebbourg calebbourg left a comment

Choose a reason for hiding this comment

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

Looks great!

@jhodapp jhodapp merged commit c3a10a5 into main Feb 26, 2024
4 checks passed
@jhodapp jhodapp deleted the 32-fix-ability-to-run-tests branch February 26, 2024 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improves existing functionality or feature
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

Fix ability to run tests
2 participants