forked from AdaGold/video-store-api
-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathVideoStoreAPI_smoke_tests.postman_collection.json
159 lines (159 loc) · 5.21 KB
/
VideoStoreAPI_smoke_tests.postman_collection.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
{
"variables": [],
"info": {
"name": "VideoStoreAPI",
"_postman_id": "1086a006-3092-326f-f301-d7d6bd4a44ff",
"description": "",
"schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json"
},
"item": [
{
"name": "List Customers",
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"// Check headers",
"tests[\"Status code is 200\"] = responseCode.code === 200;",
"",
"var contentType = postman.getResponseHeader(\"Content-Type\");",
"tests[\"Content-Type is present\"] = contentType;",
"tests[\"Content-Type is application/json\"] = contentType.has('application/json');",
"",
"// Check data format",
"var jsonData = JSON.parse(responseBody);",
"tests[\"Data is an array\"] = Array.isArray(jsonData);",
"tests[\"Many customers were sent\"] = jsonData.length > 0;",
"",
"// Save info on the first customer",
"postman.setEnvironmentVariable(\"customer_id\", jsonData[0].id);",
"postman.setEnvironmentVariable(\"customer_mcoc\", jsonData[0].movies_checked_out_count);",
"",
"// Check required fields",
"var hasId = true;",
"var hasName = true;",
"var hasRegisteredAt = true;",
"var hasPostalCode = true;",
"var hasPhone = true;",
"var hasMoviesCheckedOutCount = true;",
"",
"jsonData.forEach(function(customer) {",
" hasId = hasId && \"id\" in customer;",
" hasName = hasName && \"name\" in customer;",
" hasRegisteredAt = hasRegisteredAt && \"registered_at\" in customer;",
" hasPostalCode = hasPostalCode && \"postal_code\" in customer;",
" hasPhone = hasPhone && \"phone\" in customer;",
" hasMoviesCheckedOutCount = hasMoviesCheckedOutCount && \"movies_checked_out_count\" in customer;",
"});",
"",
"tests[\"All customers have id\"] = hasId;",
"tests[\"All customers have name\"] = hasName;",
"tests[\"All customers have registered_at\"] = hasRegisteredAt;",
"tests[\"All customers have postal_code\"] = hasPostalCode;",
"tests[\"All customers have phone\"] = hasPhone;",
"tests[\"All customers have movies_checked_out_count\"] = hasMoviesCheckedOutCount;"
]
}
}
],
"request": {
"url": "{{url}}/customers",
"method": "GET",
"header": [],
"body": {},
"description": ""
},
"response": []
},
{
"name": "List Movies",
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"// Check headers",
"tests[\"Status code is 200\"] = responseCode.code === 200;",
"",
"var contentType = postman.getResponseHeader(\"Content-Type\");",
"tests[\"Content-Type is present\"] = contentType;",
"tests[\"Content-Type is application/json\"] = contentType.has('application/json');",
"",
"// Check data format",
"var jsonData = JSON.parse(responseBody);",
"tests[\"Data is an array\"] = Array.isArray(jsonData);",
"tests[\"Many movies were sent\"] = jsonData.length > 0;",
"",
"// Save info on the first movie",
"postman.setEnvironmentVariable(\"movie_title\", jsonData[0].title);",
"",
"// Check required fields",
"var hasTitle = true;",
"var hasReleaseDate = true;",
"",
"jsonData.forEach(function(customer) {",
" hasTitle = hasTitle && \"title\" in customer;",
" hasReleaseDate = hasReleaseDate && \"release_date\" in customer;",
"});",
"",
"tests[\"All movies have title\"] = hasTitle;",
"tests[\"All movies have release_date\"] = hasReleaseDate;"
]
}
}
],
"request": {
"url": "{{url}}/movies",
"method": "GET",
"header": [],
"body": {},
"description": ""
},
"response": []
},
{
"name": "Show Movie",
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"// Check headers",
"tests[\"Status code is 200\"] = responseCode.code === 200;",
"",
"var contentType = postman.getResponseHeader(\"Content-Type\");",
"tests[\"Content-Type is present\"] = contentType;",
"tests[\"Content-Type is application/json\"] = contentType.has('application/json');",
"",
"// Check data format",
"var movie = JSON.parse(responseBody);",
"tests[\"Data is not an array\"] = !Array.isArray(movie);",
"",
"// Check required fields",
"tests[\"Movie has title\"] = \"title\" in movie;",
"tests[\"Movie has overview\"] = \"overview\" in movie;",
"tests[\"Movie has release_date\"] = \"release_date\" in movie;",
"tests[\"Movie has inventory\"] = \"inventory\" in movie;",
"tests[\"Movie has available_inventory\"] = \"available_inventory\" in movie;",
"",
"// Save available inventory for later",
"postman.setEnvironmentVariable(\"movie_ai\", movie.available_inventory);"
]
}
}
],
"request": {
"url": "{{url}}/movies/{{movie_title}}",
"method": "GET",
"header": [],
"body": {},
"description": ""
},
"response": []
}
]
}