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 new baseline /organizations endpoint tests #28

Merged
merged 8 commits into from
Jan 4, 2024

Conversation

jhodapp
Copy link
Member

@jhodapp jhodapp commented Dec 27, 2023

Description

This PR seeks to fill out blackbox tests of all the major operations one can do with our /organizations endpoint.

GitHub Issue: None

Changes

  • Moves the logging initialization functionality into its own module/struct called logging::Logger - this is to make it possible to use the logger in these (and other) tests
  • Creates a test HTTP client/server struct and impl to reuse for blackbox testing endpoints
  • Adds a test ensuring all organizations are returned by a GET with no ID specified
  • Adds a test ensuring a specific organization instance can be deleted by specifying its ID with DELETE
  • Adds a test ensuring that it's possible to create a new organization instance using POST
  • Adds a test ensuring a specific organization instance can be updated by specifying its ID with PUT

Testing Strategy

  1. Run cargo test at the root of the source tree and observe these 4 new tests pass

Expected output:

running 1 test
21:06:53 [INFO] Running tests for "entity_api" crate

21:06:54 [INFO] All "entity_api" tests completed successfully.

21:06:54 [INFO]
running 1 test
test organization::tests::find_all_returns_a_list_of_records_when_present ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.01s


running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s


21:06:54 [INFO]     Finished test [unoptimized + debuginfo] target(s) in 0.09s
     Running unittests src/lib.rs (target/debug/deps/entity_api-1c2029c6d4569097)
   Doc-tests entity_api

21:06:54 [INFO] Running tests for "web" crate

21:06:54 [INFO] All "web" tests completed successfully.

21:06:54 [INFO]
running 5 tests
test router::organization_endpoints_tests::read_returns_all_organizations ... ok
test router::organization_endpoints_tests::read_returns_expected_json_for_specified_organization ... ok
test router::organization_endpoints_tests::update_an_organization_specified_by_id ... ok
test router::organization_endpoints_tests::create_new_organizations_successfully ... ok
test router::organization_endpoints_tests::delete_two_organization_specified_by_two_ids ... ok

test result: ok. 5 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.04s

Concerns

None

@jhodapp jhodapp added the enhancement Improves existing functionality or feature label Dec 27, 2023
@jhodapp jhodapp self-assigned this Dec 28, 2023
@jhodapp jhodapp force-pushed the add_more_baseline_tests branch from 435794c to 71635fd Compare December 28, 2023 05:46
@jhodapp jhodapp marked this pull request as ready for review December 30, 2023 21:11
@jhodapp jhodapp requested a review from calebbourg December 30, 2023 21:11
@jhodapp jhodapp marked this pull request as draft January 3, 2024 18:02
@jhodapp
Copy link
Member Author

jhodapp commented Jan 3, 2024

Going back to draft PR status because I want to consolidate the repetitious Reqwest client code into a reusable structure used by each test.

@jhodapp jhodapp requested a review from qafui January 3, 2024 18:03
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.

Tests look great! Thank you for adding these. I just had one question so far.

service/src/logging.rs Outdated Show resolved Hide resolved
@jhodapp jhodapp force-pushed the add_more_baseline_tests branch from 543dbe9 to b1faaf3 Compare January 4, 2024 01:41
@jhodapp jhodapp marked this pull request as ready for review January 4, 2024 01:48
Copy link

@qafui qafui left a comment

Choose a reason for hiding this comment

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

Nice clean-up!

@jhodapp
Copy link
Member Author

jhodapp commented Jan 4, 2024

Nice clean-up!

Why thank you! 😊

@jhodapp jhodapp merged commit eff6fda into main Jan 4, 2024
4 checks passed
@jhodapp jhodapp deleted the add_more_baseline_tests branch February 24, 2024 18:14
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.

3 participants