Skip to content

Commit f50955a

Browse files
feat: Add room_id to rooms struct, update tests (#262)
1 parent 4541c6e commit f50955a

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

backend/internal/handler/rooms_test.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,13 @@ func TestRoomsHandler_FilterRooms(t *testing.T) {
4242
findRoomsFunc: func(ctx context.Context, filter *models.FilterRoomsRequest, hotelID string, cursorRoomNumber int) ([]*models.RoomWithOptionalGuestBooking, error) {
4343
return []*models.RoomWithOptionalGuestBooking{
4444
{
45-
Room: models.Room{RoomNumber: 101, Floor: 1, SuiteType: "standard", RoomStatus: "available"},
45+
Room: models.Room{
46+
ID: "530e8400-e458-41d4-a716-446655440111",
47+
RoomNumber: 101,
48+
Floor: 1,
49+
SuiteType: "standard",
50+
RoomStatus: "available",
51+
},
4652
Guests: nil,
4753
},
4854
}, nil
@@ -63,6 +69,7 @@ func TestRoomsHandler_FilterRooms(t *testing.T) {
6369

6470
body, _ := io.ReadAll(resp.Body)
6571
assert.Contains(t, string(body), `"items"`)
72+
assert.Contains(t, string(body), "530e8400-e458-41d4-a716-446655440111")
6673
assert.Contains(t, string(body), "101")
6774
assert.Contains(t, string(body), "standard")
6875
assert.Contains(t, string(body), `"has_more":false`)

backend/internal/models/rooms.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package models
22

33
type Room struct {
4+
ID string `json:"id"`
45
RoomNumber int `json:"room_number"`
56
Floor int `json:"floor"`
67
SuiteType string `json:"suite_type"`

backend/internal/repository/rooms.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func (r *RoomsRepository) FindRoomsWithOptionalGuestBookingsByFloor(ctx context.
6060
var rb models.RoomWithOptionalGuestBooking
6161
var guestsJSON json.RawMessage
6262
err := rows.Scan(
63-
&rb.RoomNumber, &rb.Floor, &rb.SuiteType, &rb.RoomStatus,
63+
&rb.ID, &rb.RoomNumber, &rb.Floor, &rb.SuiteType, &rb.RoomStatus,
6464
&guestsJSON,
6565
)
6666
if err != nil {

0 commit comments

Comments
 (0)