add tests for workspace booking contract functionality#642
Merged
yusuftomilola merged 2 commits intoDistinctCodes:mainfrom Mar 9, 2026
Merged
add tests for workspace booking contract functionality#642yusuftomilola merged 2 commits intoDistinctCodes:mainfrom
yusuftomilola merged 2 commits intoDistinctCodes:mainfrom
Conversation
|
@JoeX17 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 #609
Description:
This PR introduces test coverage for the core
book_workspacefunctionality within theworkspace_bookingsmart contract. It ensures that successful bookings calculate costs correctly and execute the required token transfers, while also verifying that the contract strictly rejects overlapping booking attempts.Key Changes:
Added
test_book_workspace_success:Utilizes
setup_tokento mint 10,000 tokens to thememberaddress.Registers a Meeting Room workspace (
"ws-001", capacity10, rate1,000/hr).Creates a 2-hour booking (
booking-001) and asserts that the stored booking fields match the expected data (workspace_id,member,status: Active).Validates the contract's cost calculation logic (using ceiling division), ensuring
amount_paidequals2,000.Instantiates the
TokenClientto verify the member's token balance correctly decreased from 10,000 to 8,000 after the transaction.Added
test_book_workspace_conflict_fails:Registers a Hot Desk workspace (
capacity 1).Creates an initial 1-hour booking.
Attempts to create a second booking that overlaps with the first timeframe.
Ensures the contract successfully rejects the overlapping booking by panicking with the expected
BookingConflict = 7error (Error(Contract, #7)).Files Modified:
contracts/workspace_booking/src/test.rsAcceptance Criteria Met:
cargo test -p workspace_booking.test_book_workspace_successverifies the token balance decreased by exactly theamount_paid.test_book_workspace_successverifies the cost calculation logic (amount_paid == 2_000for a 2-hour booking at1_000/hr).test_book_workspace_conflict_failscorrectly catches theError(Contract, #7)panic.