@@ -11,7 +11,7 @@ testcases:
1111 assertions :
1212 - result.err ShouldBeEmpty
1313
14- - name : Retrieve reservations
14+ - name : Retrieve existings reservations
1515 steps :
1616 - type : http
1717 method : GET
@@ -21,7 +21,7 @@ testcases:
2121 - result.bodyjson.__type__ ShouldEqual Array
2222 - result.bodyjson.__len__ ShouldEqual 3
2323
24- - name : Retrieve one existing reservation
24+ - name : Retrieve an existing reservation
2525 steps :
2626 - type : http
2727 method : GET
@@ -33,23 +33,95 @@ testcases:
3333 - result.bodyjson.hotel_id ShouldEqual 2
3434 - result.bodyjson.room_number ShouldEqual 3
3535
36- - name : Try to retrieve unexisting reservation
36+ - name : Try to retrieve an unexisting reservation
3737 steps :
3838 - type : http
3939 method : GET
40- url : " {{.myapp}}/reservations/4 "
40+ url : " {{.myapp}}/reservations/5 "
4141 assertions :
4242 - result.statuscode ShouldEqual 404
43- - " result.bodyjson.message ShouldEqual unable to retrieve reservation for id '4 ': not found"
43+ - " result.bodyjson.message ShouldEqual unable to retrieve reservation for id '5 ': not found"
4444
45- - name : Get one reservation
45+ - name : Create a reservation with missing data
4646 steps :
4747 - type : http
48- method : GET
49- url : " {{.myapp}}/reservations/1"
48+ method : POST
49+ url : " {{.mock_server}}/mocks?session=create_reservation_missing_data"
50+ bodyFile : ./assets/mocks/create_reservation_not_found.mocks.yml
5051 assertions :
5152 - result.statuscode ShouldEqual 200
52- - result.bodyjson.id ShouldEqual 1
53- - result.bodyjson.user_id ShouldEqual 2
54- - result.bodyjson.hotel_id ShouldEqual 2
55- - result.bodyjson.room_number ShouldEqual 3
53+ - type : http
54+ method : POST
55+ url : " {{.myapp}}/reservations"
56+ headers :
57+ Content-Type : application/json
58+ body : |
59+ {
60+ "hotel": "hotel1",
61+ "user": "user1",
62+ "rooms": 2
63+ }
64+ assertions :
65+ - result.statuscode ShouldEqual 500
66+ - ' result.bodyjson.message ShouldEqual unable to retrieve user "user1": request failed with code 404: not found'
67+ - type : http
68+ method : POST
69+ url : " {{.myapp}}/reservations"
70+ headers :
71+ Content-Type : application/json
72+ body : |
73+ {
74+ "hotel": "hotel2",
75+ "user": "user2",
76+ "rooms": 2
77+ }
78+ assertions :
79+ - result.statuscode ShouldEqual 500
80+ - ' result.bodyjson.message ShouldEqual unable to retrieve hotel "hotel2": request failed with code 404: not found'
81+
82+ - name : Create a reservation not enough rooms
83+ steps :
84+ - type : http
85+ method : POST
86+ url : " {{.mock_server}}/mocks?session=create_reservation_not_enough_rooms"
87+ bodyFile : ./assets/mocks/create_reservation_ok.mocks.yml
88+ assertions :
89+ - result.statuscode ShouldEqual 200
90+ - type : http
91+ method : POST
92+ url : " {{.myapp}}/reservations"
93+ headers :
94+ Content-Type : application/json
95+ body : |
96+ {
97+ "hotel": "hotel1",
98+ "user": "user1",
99+ "rooms": 20
100+ }
101+ assertions :
102+ - result.statuscode ShouldEqual 409
103+ - " result.bodyjson.message ShouldEqual can't create reservation: not enough room available"
104+
105+ - name : Create a reservation ok
106+ steps :
107+ - type : http
108+ method : POST
109+ url : " {{.mock_server}}/mocks?session=create_reservation_ok"
110+ bodyFile : ./assets/mocks/create_reservation_ok.mocks.yml
111+ assertions :
112+ - result.statuscode ShouldEqual 200
113+ - type : http
114+ method : POST
115+ url : " {{.myapp}}/reservations"
116+ headers :
117+ Content-Type : application/json
118+ body : |
119+ {
120+ "hotel": "hotel1",
121+ "user": "user1",
122+ "rooms": 2
123+ }
124+ assertions :
125+ - result.statuscode ShouldEqual 200
126+ - result.bodyjson.id ShouldNotBeEmpty
127+
0 commit comments