forked from vieter-v/libvieter
chore: Package module now follows the naming and structure conventions of libvieter.
This commit is contained in:
parent
1ccd4101af
commit
76e4adae92
13 changed files with 224 additions and 178 deletions
|
|
@ -1,7 +1,7 @@
|
|||
#include "acutest.h"
|
||||
#include "package.h"
|
||||
#include "vieter_package_internal.h"
|
||||
|
||||
void test_pkg_info_parse() {
|
||||
void test_info_parse() {
|
||||
FILE *f = fopen("./test/package/.PKGINFO", "r");
|
||||
TEST_ASSERT_(f != NULL, "could not find test .PKGINFO file in ./test/package ");
|
||||
fseek(f, 0L, SEEK_END);
|
||||
|
|
@ -11,34 +11,35 @@ void test_pkg_info_parse() {
|
|||
char *pkg_info_str = malloc(size);
|
||||
fread(pkg_info_str, 1, size, f);
|
||||
fclose(f);
|
||||
PkgInfo *pkg_info = package_info_init();
|
||||
package_info_parse(pkg_info, pkg_info_str);
|
||||
|
||||
TEST_CHECK(!strcmp(pkg_info->name, "xcursor-dmz"));
|
||||
TEST_CHECK(!strcmp(pkg_info->base, "xcursor-dmz"));
|
||||
TEST_CHECK(!strcmp(pkg_info->version, "0.4.5-2"));
|
||||
TEST_CHECK(!strcmp(pkg_info->description, "Style neutral, scalable cursor theme"));
|
||||
TEST_CHECK(!strcmp(pkg_info->url, "https://packages.debian.org/sid/dmz-cursor-theme"));
|
||||
TEST_CHECK(pkg_info->build_date == 1673751613);
|
||||
TEST_CHECK(!strcmp(pkg_info->packager, "Unknown Packager"));
|
||||
TEST_CHECK(pkg_info->size == 3469584);
|
||||
TEST_CHECK(!strcmp(pkg_info->arch, "any"));
|
||||
pkg_info *info = vieter_package_info_init();
|
||||
vieter_package_info_parse(info, pkg_info_str);
|
||||
|
||||
TEST_CHECK(!strcmp(pkg_info->licenses->array[0], "MIT"));
|
||||
TEST_CHECK(!strcmp(pkg_info->replaces->array[0], "test1"));
|
||||
TEST_CHECK(!strcmp(pkg_info->groups->array[0], "x11"));
|
||||
TEST_CHECK(!strcmp(pkg_info->conflicts->array[0], "test2"));
|
||||
TEST_CHECK(!strcmp(pkg_info->conflicts->array[1], "test3"));
|
||||
TEST_CHECK(!strcmp(pkg_info->provides->array[0], "test4"));
|
||||
TEST_CHECK(!strcmp(pkg_info->depends->array[0], "test5"));
|
||||
TEST_CHECK(!strcmp(pkg_info->depends->array[1], "test6"));
|
||||
TEST_CHECK(!strcmp(pkg_info->optdepends->array[0], "test7"));
|
||||
TEST_CHECK(!strcmp(pkg_info->makedepends->array[0], "xorg-xcursorgen"));
|
||||
TEST_CHECK(!strcmp(pkg_info->checkdepends->array[0], "test8"));
|
||||
TEST_CHECK(!strcmp(info->name, "xcursor-dmz"));
|
||||
TEST_CHECK(!strcmp(info->base, "xcursor-dmz"));
|
||||
TEST_CHECK(!strcmp(info->version, "0.4.5-2"));
|
||||
TEST_CHECK(!strcmp(info->description, "Style neutral, scalable cursor theme"));
|
||||
TEST_CHECK(!strcmp(info->url, "https://packages.debian.org/sid/dmz-cursor-theme"));
|
||||
TEST_CHECK(info->build_date == 1673751613);
|
||||
TEST_CHECK(!strcmp(info->packager, "Unknown Packager"));
|
||||
TEST_CHECK(info->size == 3469584);
|
||||
TEST_CHECK(!strcmp(info->arch, "any"));
|
||||
|
||||
TEST_CHECK(!strcmp(info->licenses->array[0], "MIT"));
|
||||
TEST_CHECK(!strcmp(info->replaces->array[0], "test1"));
|
||||
TEST_CHECK(!strcmp(info->groups->array[0], "x11"));
|
||||
TEST_CHECK(!strcmp(info->conflicts->array[0], "test2"));
|
||||
TEST_CHECK(!strcmp(info->conflicts->array[1], "test3"));
|
||||
TEST_CHECK(!strcmp(info->provides->array[0], "test4"));
|
||||
TEST_CHECK(!strcmp(info->depends->array[0], "test5"));
|
||||
TEST_CHECK(!strcmp(info->depends->array[1], "test6"));
|
||||
TEST_CHECK(!strcmp(info->optdepends->array[0], "test7"));
|
||||
TEST_CHECK(!strcmp(info->makedepends->array[0], "xorg-xcursorgen"));
|
||||
TEST_CHECK(!strcmp(info->checkdepends->array[0], "test8"));
|
||||
}
|
||||
|
||||
void test_pkg_read_archive_files() {
|
||||
Pkg *pkg = package_read_archive("./test/package/xcursor-dmz-0.4.5-2-any.pkg.tar.zst");
|
||||
Pkg *pkg = vieter_package_read_archive("./test/package/xcursor-dmz-0.4.5-2-any.pkg.tar.zst");
|
||||
TEST_ASSERT_(pkg != NULL, "failure parsing pkg archive");
|
||||
|
||||
FILE *f = fopen("./test/package/files", "r");
|
||||
|
|
@ -59,10 +60,10 @@ void test_pkg_read_archive_files() {
|
|||
}
|
||||
|
||||
void test_pkg_read_archive_desc() {
|
||||
Pkg *pkg = package_read_archive("./test/package/xcursor-dmz-0.4.5-2-any.pkg.tar.zst");
|
||||
Pkg *pkg = vieter_package_read_archive("./test/package/xcursor-dmz-0.4.5-2-any.pkg.tar.zst");
|
||||
TEST_ASSERT_(pkg != NULL, "failure parsing pkg archive");
|
||||
|
||||
char *description = package_to_description(pkg);
|
||||
char *description = vieter_package_to_description(pkg);
|
||||
|
||||
FILE *f = fopen("./test/package/desc", "r");
|
||||
TEST_ASSERT_(f != NULL, "could not find test desc file in ./test/package");
|
||||
|
|
@ -77,8 +78,8 @@ void test_pkg_read_archive_desc() {
|
|||
}
|
||||
|
||||
TEST_LIST = {
|
||||
{"pkg_info_valid_parse", test_pkg_info_parse},
|
||||
{"pkg_read_archive_files", test_pkg_read_archive_files},
|
||||
{"pkg_read_archive_desc", test_pkg_read_archive_desc},
|
||||
{".PKGINFO parse", test_info_parse},
|
||||
{"files array creation", test_pkg_read_archive_files},
|
||||
{"desc file creation", test_pkg_read_archive_desc},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue