]> git.ipfire.org Git - pakfire.git/blame - tests/libpakfire/package.c
packages: Make constructor function more similar to others
[pakfire.git] / tests / libpakfire / package.c
CommitLineData
c811b282
MT
1/*#############################################################################
2# #
3# Pakfire - The IPFire package management system #
4# Copyright (C) 2021 Pakfire development team #
5# #
6# This program is free software: you can redistribute it and/or modify #
7# it under the terms of the GNU General Public License as published by #
8# the Free Software Foundation, either version 3 of the License, or #
9# (at your option) any later version. #
10# #
11# This program is distributed in the hope that it will be useful, #
12# but WITHOUT ANY WARRANTY; without even the implied warranty of #
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
14# GNU General Public License for more details. #
15# #
16# You should have received a copy of the GNU General Public License #
17# along with this program. If not, see <http://www.gnu.org/licenses/>. #
18# #
19#############################################################################*/
20
21#include <stdio.h>
22
23#include <pakfire/package.h>
24#include <pakfire/util.h>
25
26#include "../testsuite.h"
27
28static int test_create(const struct test* t) {
29 struct pakfire_package* pkg = NULL;
30 int r = EXIT_FAILURE;
31
33ad2a01 32 ASSERT_SUCCESS(pakfire_package_create(&pkg, t->pakfire, NULL, "test", "1.0-1", "src"));
c811b282 33
7fbede3a
MT
34 ASSERT_STRING_EQUALS(pakfire_package_get_string(pkg, PAKFIRE_PKG_NAME), "test");
35 ASSERT_STRING_EQUALS(pakfire_package_get_string(pkg, PAKFIRE_PKG_EVR), "1.0-1");
36 ASSERT_STRING_EQUALS(pakfire_package_get_string(pkg, PAKFIRE_PKG_ARCH), "src");
37
38 // Summary
39 ASSERT_SUCCESS(pakfire_package_set_string(pkg, PAKFIRE_PKG_SUMMARY, "SUMMARY"));
40 ASSERT_STRING_EQUALS(pakfire_package_get_string(pkg, PAKFIRE_PKG_SUMMARY), "SUMMARY");
c811b282
MT
41
42 // Everything passed
43 r = EXIT_SUCCESS;
44
45FAIL:
46 if (pkg)
47 pakfire_package_unref(pkg);
48
49 return r;
50}
51
52int main(int argc, const char* argv[]) {
53 testsuite_add_test(test_create);
54
55 return testsuite_run(argc, argv);
56}