Skip to content
This repository was archived by the owner on Jan 20, 2026. It is now read-only.

Postman tests for compulsory part 2#28

Merged
juuwel merged 3 commits into
mainfrom
postman-tests
Oct 27, 2025
Merged

Postman tests for compulsory part 2#28
juuwel merged 3 commits into
mainfrom
postman-tests

Conversation

@juuwel
Copy link
Copy Markdown
Member

@juuwel juuwel commented Oct 27, 2025

This pull request introduces several improvements to the testing and initialization of the HotelBooking application, with a focus on supporting a dedicated test environment and enhancing automated API tests. The most significant changes include the addition of a test database initializer, improved environment configuration for tests, and more robust Postman API test cases.

Test Environment and Database Initialization:

  • Added a new TestDbInitializer class to seed the test database with sample data, ensuring consistent test conditions. The application now uses this initializer when running in the "Test" environment, while the regular DbInitializer is used for development. (HotelBooking.Infrastructure/TestDbInitializer.cs, HotelBooking.WebApi/Program.cs) [1] [2]
  • Updated the application startup logic to detect the "Test" environment and seed the database accordingly. Also added a "Test" profile to the launch settings for easier local testing. (HotelBooking.WebApi/Program.cs, HotelBooking.WebApi/Properties/launchSettings.json) [1] [2]

CI/CD and Automated Testing Enhancements:

  • Modified the GitHub Actions workflow to set ASPNETCORE_ENVIRONMENT to "Test" during CI runs, ensuring the test database and configuration are used. (.github/workflows/build-test.yaml)
  • Enhanced the Postman test step to use iteration data, allowing multiple test cases to be run automatically with different expected outcomes. (.github/workflows/build-test.yaml, Postman/bookingTestCases.json) [1] [2]

API Testing Improvements:

  • Updated the Postman collection to use pre-request scripts for dynamically generating request payloads and setting expected status codes based on iteration data. Also added explicit test cases for "Bad Request" and "Conflict" responses. (Postman/HotelBooking.postman_collection.json) [1] [2]

Booking Creation Logic:

  • Improved the CreateBooking method to fetch and assign the full Room entity to the booking, ensuring the booking object is fully populated before saving. (HotelBooking.Core/Services/BookingManager.cs)

@juuwel juuwel marked this pull request as ready for review October 27, 2025 17:40
@juuwel juuwel requested a review from Copilot October 27, 2025 17:40
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances the test infrastructure for the HotelBooking application by introducing a dedicated test environment with its own database seeding logic and expanding automated API testing capabilities through Postman iteration data.

Key changes:

  • Introduced TestDbInitializer to seed a test-specific database with predefined data for consistent testing
  • Added dynamic Postman test cases using iteration data to verify success, conflict, and bad request scenarios
  • Updated CI/CD workflow to use the Test environment with iteration-based API testing

Reviewed Changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
Postman/bookingTestCases.json New iteration data file defining test cases for success (201), conflict (409), and bad request (400) scenarios
Postman/HotelBooking.postman_collection.json Added pre-request scripts to dynamically generate payloads and test scripts to validate expected status codes
HotelBooking.WebApi/Properties/launchSettings.json Added "test" launch profile for running the application in Test environment locally
HotelBooking.WebApi/Program.cs Refactored database initialization to use different initializers based on environment (Development vs Test)
HotelBooking.Infrastructure/TestDbInitializer.cs New test database initializer that seeds customers, rooms, and bookings with specific date ranges
HotelBooking.Core/Services/BookingManager.cs Enhanced CreateBooking to populate the Room property on the booking object
.github/workflows/build-test.yaml Updated to set Test environment and use iteration data for Postman tests
Comments suppressed due to low confidence (2)

Postman/HotelBooking.postman_collection.json:1

  • The pre-request script uses the same randomId for customerId and roomId, which will likely not match existing entities in the test database. The TestDbInitializer creates specific customers and rooms with their own IDs. Consider using fixed IDs that correspond to the seeded test data to ensure valid bookings.
{

Postman/HotelBooking.postman_collection.json:1

  • The pre-request script uses the same randomId for customerId and roomId, which will likely not match existing entities in the test database. The TestDbInitializer creates specific customers and rooms with their own IDs. Consider using fixed IDs that correspond to the seeded test data to ensure valid bookings.
{

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Postman/HotelBooking.postman_collection.json
Comment thread HotelBooking.Core/Services/BookingManager.cs
Comment thread HotelBooking.Infrastructure/TestDbInitializer.cs
@juuwel juuwel merged commit 8fc54e8 into main Oct 27, 2025
1 check passed
@juuwel juuwel deleted the postman-tests branch October 27, 2025 17:42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants