@@ -26,13 +26,15 @@ class UpdateResponseParserTest {
2626 val responseBody =
2727 """
2828 {
29- "updateAvailable": true,
30- "id": "update-123",
31- "buildVersion": "2.0.0",
32- "buildNumber": 42,
33- "downloadUrl": "https://example.com/download",
34- "appName": "Test App",
35- "createdDate": "2023-10-01T00:00:00Z"
29+ "update": {
30+ "id": "update-123",
31+ "build_version": "2.0.0",
32+ "build_number": 42,
33+ "download_url": "https://example.com/download",
34+ "app_name": "Test App",
35+ "created_date": "2023-10-01T00:00:00Z"
36+ },
37+ "current": null
3638 }
3739 """
3840 .trimIndent()
@@ -54,7 +56,15 @@ class UpdateResponseParserTest {
5456 val responseBody =
5557 """
5658 {
57- "updateAvailable": false
59+ "update": null,
60+ "current": {
61+ "id": "current-123",
62+ "build_version": "1.0.0",
63+ "build_number": 10,
64+ "download_url": "https://example.com/download",
65+ "app_name": "Test App",
66+ "created_date": "2023-09-01T00:00:00Z"
67+ }
5868 }
5969 """
6070 .trimIndent()
@@ -65,11 +75,18 @@ class UpdateResponseParserTest {
6575 }
6676
6777 @Test
68- fun `parseResponse returns UpToDate when updateAvailable is missing` () {
78+ fun `parseResponse returns UpToDate when update is missing` () {
6979 val responseBody =
7080 """
7181 {
72- "someOtherField": "value"
82+ "current": {
83+ "id": "current-123",
84+ "build_version": "1.0.0",
85+ "build_number": 10,
86+ "download_url": "https://example.com/download",
87+ "app_name": "Test App",
88+ "created_date": "2023-09-01T00:00:00Z"
89+ }
7390 }
7491 """
7592 .trimIndent()
@@ -123,8 +140,9 @@ class UpdateResponseParserTest {
123140 val responseBody =
124141 """
125142 {
126- "updateAvailable": true,
127- "buildVersion": "2.0.0"
143+ "update": {
144+ "build_version": "2.0.0"
145+ }
128146 }
129147 """
130148 .trimIndent()
@@ -144,10 +162,14 @@ class UpdateResponseParserTest {
144162 val responseBody =
145163 """
146164 {
147- "updateAvailable": true,
148- "id": "update-123",
149- "buildVersion": "2.0.0",
150- "downloadUrl": "https://example.com/download"
165+ "update": {
166+ "id": "update-123",
167+ "build_version": "2.0.0",
168+ "build_number": 0,
169+ "download_url": "https://example.com/download",
170+ "app_name": "",
171+ "created_date": ""
172+ }
151173 }
152174 """
153175 .trimIndent()
@@ -181,10 +203,14 @@ class UpdateResponseParserTest {
181203 val responseBody =
182204 """
183205 {
184- "updateAvailable": true,
185- "id": null,
186- "buildVersion": "2.0.0",
187- "downloadUrl": "https://example.com/download"
206+ "update": {
207+ "id": null,
208+ "build_version": "2.0.0",
209+ "build_number": 10,
210+ "download_url": "https://example.com/download",
211+ "app_name": "Test App",
212+ "created_date": "2023-10-01T00:00:00Z"
213+ }
188214 }
189215 """
190216 .trimIndent()
@@ -204,9 +230,13 @@ class UpdateResponseParserTest {
204230 val responseBody =
205231 """
206232 {
207- "updateAvailable": true,
208- "buildVersion": "2.0.0",
209- "downloadUrl": "https://example.com/download"
233+ "update": {
234+ "build_version": "2.0.0",
235+ "build_number": 10,
236+ "download_url": "https://example.com/download",
237+ "app_name": "Test App",
238+ "created_date": "2023-10-01T00:00:00Z"
239+ }
210240 }
211241 """
212242 .trimIndent()
@@ -226,9 +256,13 @@ class UpdateResponseParserTest {
226256 val responseBody =
227257 """
228258 {
229- "updateAvailable": true,
230- "id": "update-123",
231- "downloadUrl": "https://example.com/download"
259+ "update": {
260+ "id": "update-123",
261+ "build_number": 10,
262+ "download_url": "https://example.com/download",
263+ "app_name": "Test App",
264+ "created_date": "2023-10-01T00:00:00Z"
265+ }
232266 }
233267 """
234268 .trimIndent()
@@ -248,9 +282,13 @@ class UpdateResponseParserTest {
248282 val responseBody =
249283 """
250284 {
251- "updateAvailable": true,
252- "id": "update-123",
253- "buildVersion": "2.0.0"
285+ "update": {
286+ "id": "update-123",
287+ "build_version": "2.0.0",
288+ "build_number": 10,
289+ "app_name": "Test App",
290+ "created_date": "2023-10-01T00:00:00Z"
291+ }
254292 }
255293 """
256294 .trimIndent()
@@ -270,8 +308,11 @@ class UpdateResponseParserTest {
270308 val responseBody =
271309 """
272310 {
273- "updateAvailable": true,
274- "buildNumber": 42
311+ "update": {
312+ "build_number": 42,
313+ "app_name": "Test App",
314+ "created_date": "2023-10-01T00:00:00Z"
315+ }
275316 }
276317 """
277318 .trimIndent()
@@ -293,10 +334,14 @@ class UpdateResponseParserTest {
293334 val responseBody =
294335 """
295336 {
296- "updateAvailable": true,
297- "id": "null",
298- "buildVersion": "2.0.0",
299- "downloadUrl": "https://example.com/download"
337+ "update": {
338+ "id": "null",
339+ "build_version": "2.0.0",
340+ "build_number": 10,
341+ "download_url": "https://example.com/download",
342+ "app_name": "Test App",
343+ "created_date": "2023-10-01T00:00:00Z"
344+ }
300345 }
301346 """
302347 .trimIndent()
0 commit comments