forked from rpm-software-management/librepo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_package_downloader.c
78 lines (65 loc) · 2.05 KB
/
test_package_downloader.c
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
#define _GNU_SOURCE
#include <stdlib.h>
#include <errno.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "fixtures.h"
#include "testsys.h"
#include "test_package_downloader.h"
#include "librepo/librepo.h"
#include "librepo/rcodes.h"
#include "librepo/package_downloader.h"
START_TEST(test_package_downloader_new_and_free)
{
LrPackageTarget *target;
GError *err = NULL;
// Init with only basic options
target = lr_packagetarget_new(NULL, "url", NULL, 0, NULL, 0, NULL, FALSE,
NULL, NULL, &err);
fail_if(!target);
fail_if(err);
fail_if(strcmp(target->relative_url, "url"));
fail_if(target->dest);
fail_if(target->base_url);
fail_if(target->checksum_type != 0);
fail_if(target->checksum);
fail_if(target->resume != FALSE);
fail_if(target->progresscb);
fail_if(target->cbdata);
fail_if(target->local_path);
fail_if(target->err);
lr_packagetarget_free(target);
target = NULL;
// Init with all options
target = lr_packagetarget_new(NULL, "url", "dest", LR_CHECKSUM_SHA384,
"xxx", 0, "baseurl", TRUE, (LrProgressCb) 22,
(void *) 33, &err);
fail_if(!target);
fail_if(err);
fail_if(strcmp(target->relative_url, "url"));
fail_if(strcmp(target->dest, "dest"));
fail_if(strcmp(target->base_url, "baseurl"));
fail_if(target->checksum_type != LR_CHECKSUM_SHA384);
fail_if(strcmp(target->checksum, "xxx"));
fail_if(target->resume != TRUE);
fail_if(target->progresscb != (LrProgressCb) 22);
fail_if(target->cbdata != (void *) 33);
fail_if(target->local_path);
fail_if(target->err);
lr_packagetarget_free(target);
target = NULL;
}
END_TEST
Suite *
package_downloader_suite(void)
{
Suite *s = suite_create("package_downloader");
TCase *tc = tcase_create("Main");
tcase_add_test(tc, test_package_downloader_new_and_free);
suite_add_tcase(s, tc);
return s;
}