add tests for workspace booking contract functionality#641
Merged
yusuftomilola merged 2 commits intoDistinctCodes:mainfrom Mar 9, 2026
Merged
add tests for workspace booking contract functionality#641yusuftomilola merged 2 commits intoDistinctCodes:mainfrom
yusuftomilola merged 2 commits intoDistinctCodes:mainfrom
Conversation
|
@Tinna23 is attempting to deploy a commit to the naijabuz's projects Team on Vercel. A member of the Team first needs to authorize it. |
yusuftomilola
approved these changes
Mar 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #608
Description:
This PR builds upon the foundational test setup to introduce comprehensive test coverage for the workspace registration flow in the
workspace_bookingsmart contract. It verifies the happy path for creating a workspace, as well as the expected failure modes for duplicate entries and unauthorized access.Key Changes:
Added
test_register_workspace_success: * Initializes the contract and successfully registers a new workspace ("ws-001","Hot Desk A",WorkspaceType::HotDesk, capacity1, rate500).Verifies the state by querying
get_workspaceand asserting that all fields (name,workspace_type,capacity,hourly_rate,is_available) are correctly stored.Asserts that
get_all_workspaces().len() == 1.Added
test_register_workspace_duplicate_id_fails: * Verifies that attempting to register the exact same workspace ID ("ws-001") twice triggers a panic with the expectedWorkspaceAlreadyExists = 5error (Error(Contract, #5)).Added
test_register_workspace_non_admin_fails: * Generates a separatenon_adminaddress and attempts to callregister_workspace.Ensures the contract panics with the expected
Unauthorized = 2error (Error(Contract, #2)).Environment Setup: Utilized
env.mock_all_auths()across tests to uniformly bypass authorization checks during testing.Files Modified:
contracts/workspace_booking/src/test.rsAcceptance Criteria Met:
cargo test -p workspace_booking.test_register_workspace_successcorrectly asserts all workspace fields.test_register_workspace_duplicate_id_failscorrectly catches theError(Contract, #5)panic.test_register_workspace_non_admin_failscorrectly catches theError(Contract, #2)panic.