COS301-SE-2024 / occupi

A system to record and predict office occupancy on a day to day basis
https://occupi.framer.ai/
MIT License
12 stars 0 forks source link

[BUG] Failing tests in handlers_test.go #153

Closed waveyboym closed 4 months ago

waveyboym commented 4 months ago

Describe the bug 4 tests are failing on the backend. Names are:

  1. TestCancelBooking
  2. TestBookRoom

To Reproduce Steps to reproduce the behavior:

  1. Switch to the database-access-improvements branch and cd occupi-backend
  2. Run occupi.bat test
  3. Observe failing tests

Expected behavior All tests should pass

Screenshots image image

Logs

FAIL tests

=== Failed
=== FAIL: tests TestCancelBooking/Valid_Request (10.04s)
[GIN] 2024/07/05 - 20:01:08 | 500 |   10.0357823s |                 | POST     "/api/book-room"
    testing.go:1490: test executed panic(nil) or runtime.Goexit: subtest may have called FailNow on a parent test
    --- FAIL: TestCancelBooking/Valid_Request (10.04s)

=== FAIL: tests TestCancelBooking (10.13s)
[GIN] 2024/07/05 - 20:00:58 | 200 |            0s |                 | GET      "/ping-auth"
    handlers_test.go:351: could not create mock booking: expected status 200 but got 500

=== FAIL: tests TestBookRoom/Valid_Request (42.87s)
[GIN] 2024/07/05 - 20:01:51 | 500 |   42.8677488s |                 | POST     "/api/book-room"
    handlers_test.go:536:
                Error Trace:    C:/School Work/Year 3 Semester 1/COS 301 Notes/Capstone/occupi/occupi-backend/tests/handlers_test.go:536
                Error:          Not equal:
                                expected: 200
                                actual  : 500
                Test:           TestBookRoom/Valid_Request
                Messages:       handler returned wrong status code
    handlers_test.go:545:
                Error Trace:    C:/School Work/Year 3 Semester 1/COS 301 Notes/Capstone/occupi/occupi-backend/tests/handlers_test.go:545
                Error:          Not equal:
                                expected: "Successfully booked!"
                                actual  : "Failed to send booking email"

                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -1 +1 @@
                                -Successfully booked!
                                +Failed to send booking email
                Test:           TestBookRoom/Valid_Request
                Messages:       handler returned unexpected message
    handlers_test.go:549:
                Error Trace:    C:/School Work/Year 3 Semester 1/COS 301 Notes/Capstone/occupi/occupi-backend/tests/handlers_test.go:549
                Error:          Should NOT be empty, but was <nil>
                                --- Expected
                                +++ Actual
                                @@ -1 +1 @@
                                -Successfully booked!
                                +Failed to send booking email
                Test:           TestBookRoom/Valid_Request
                Messages:       handler returned unexpected message
    handlers_test.go:549:
                Error Trace:    C:/School Work/Year 3 Semester 1/COS 301 Notes/Capstone/occupi/occupi-backend/tests/handlers_test.go:549
                Error:          Should NOT be empty, but was <nil>
                                @@ -1 +1 @@
                                -Successfully booked!
                                +Failed to send booking email
                Test:           TestBookRoom/Valid_Request
                Messages:       handler returned unexpected message
    handlers_test.go:549:
                Error Trace:    C:/School Work/Year 3 Semester 1/COS 301 Notes/Capstone/occupi/occupi-backend/tests/handlers_test.go:549
                Error:          Should NOT be empty, but was <nil>
                Test:           TestBookRoom/Valid_Request
                Messages:       handler returned unexpected message
    handlers_test.go:549:
                Error Trace:    C:/School Work/Year 3 Semester 1/COS 301 Notes/Capstone/occupi/occupi-backend/tests/handlers_test.go:549
                Error:          Should NOT be empty, but was <nil>
                Error Trace:    C:/School Work/Year 3 Semester 1/COS 301 Notes/Capstone/occupi/occupi-backend/tests/handlers_test.go:549
                Error:          Should NOT be empty, but was <nil>
                Test:           TestBookRoom/Valid_Request
                Messages:       booking ID should not be empty
                Messages:       booking ID should not be empty
    --- FAIL: TestBookRoom/Valid_Request (42.87s)
    --- FAIL: TestBookRoom/Valid_Request (42.87s)

=== FAIL: tests TestBookRoom (43.00s)
[GIN] 2024/07/05 - 20:01:08 | 200 |            0s |                 | GET      "/ping-auth"

DONE 166 tests, 4 failures in 145.452s

Desktop (please complete the following information):

Additional context N/A

waveyboym commented 4 months ago

139 might be linked to this issue and may offer a resolution, @Rethakgetse-Manaka , may you confirm if I can comment out these tests for no until we can refactor handlers_test.go. Either way, the file will need to be renamed to api_handlers_test.go

Rethakgetse-Manaka commented 4 months ago

Yeah we can because of the new addition of cache