Skip to content

Commit 6271fd1

Browse files
sidt4joebonrichie
authored andcommitted
Add details() tests for 'size' and 'download-size' properties
1 parent 87100e8 commit 6271fd1

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/pk-self-test.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838

3939

4040
#define PK_TRANSACTION_ERROR_INPUT_INVALID 14
41+
#define GET_DETAILS_TEST_DATA "details\tgimp;3.0.4-84;x86_64;Solus\tGNU Image Manipulation Program\tGPL-3.0-or-later\tmultimedia\tGIMP is a mature image editor.\thttps://www.gimp.org/\t"
4142

4243
/** ver:1.0 ***********************************************************/
4344
static GMainLoop *_test_loop = NULL;
@@ -414,6 +415,22 @@ pk_test_backend_spawn_func (void)
414415
ret = pk_backend_spawn_inject_data (backend_spawn, job, "allow-cancel\tbrian", NULL);
415416
g_assert_true (!ret);
416417

418+
/* test pk_backend_spawn_inject_data details - valid (install size, download size) */
419+
ret = pk_backend_spawn_inject_data (backend_spawn, job, GET_DETAILS_TEST_DATA "145158504\t20920696", NULL);
420+
g_assert_true (ret);
421+
422+
/* test pk_backend_spawn_inject_data details - valid (huge install size, huge download size) - actual sizes from "0ad-data;0.27.0-11;x86_64;Solus" */
423+
ret = pk_backend_spawn_inject_data (backend_spawn, job, GET_DETAILS_TEST_DATA "3526938164\t1368603575", NULL);
424+
g_assert_true (ret);
425+
426+
/* test pk_backend_spawn_inject_data details - invalid (install size, invalid_download size) */
427+
ret = pk_backend_spawn_inject_data (backend_spawn, job, GET_DETAILS_TEST_DATA "INVALID-SIZE\t1368603575", NULL);
428+
g_assert_true (!ret);
429+
430+
/* test pk_backend_spawn_inject_data details - invalid (install size, invalid_download size) */
431+
ret = pk_backend_spawn_inject_data (backend_spawn, job, GET_DETAILS_TEST_DATA "145158504\tINVALID-DOWNLOAD-SIZE", NULL);
432+
g_assert_true (!ret);
433+
417434
/* convert proxy uri (bare) */
418435
uri = pk_backend_convert_uri ("username:password@server:port");
419436
g_assert_cmpstr (uri, ==, "http://username:password@server:port/");

0 commit comments

Comments
 (0)