libmpm

morphux C package management library
Log | Files | Refs | Submodules | README | LICENSE | git clone https://git.ne02ptzero.me/git/libmpm

commit 7daee1519e519775c740910ac156ee3f70406034
parent 8f2cb17b0bf9b95b96a47b2892733efb487059d5
Author: Ne02ptzero <louis@ne02ptzero.me>
Date:   Wed, 12 Apr 2017 19:36:18 +0200

Add(Tests): Add some news tests for packer_create_archive

Diffstat:
Minc/packer.h | 1+
Msrc/packer.c | 1+
Mtests/test_packer.c | 23++++++++++++++++++++++-
3 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/inc/packer.h b/inc/packer.h @@ -24,6 +24,7 @@ # define PACKER_DEF_CONF_FN "package.json" # define PACKER_DEF_EXT ".mpx" +# define PACKER_MPX_MAGIC "MPX" typedef enum packer_type_e { PACKER_TYPE_DIRECTORY, diff --git a/src/packer.c b/src/packer.c @@ -419,6 +419,7 @@ MPX_STATIC void write_package_header(FILE *fd, packer_t *ctx) { packer_conf_opt_t *opt = NULL; const char *tmp_str = NULL; + fprintf(fd, PACKER_MPX_MAGIC); fprintf(fd, "%s%c", h->package->name, 0); fprintf(fd, "%s%c", h->package->version, 0); fprintf(fd, "%s%c", h->package->description, 0); diff --git a/tests/test_packer.c b/tests/test_packer.c @@ -262,7 +262,7 @@ TEST(packer_header_deps_init) { } TEST(packer_create_archive_1) { - packer_t *ptr; + packer_t *ptr; ptr = packer_init_dir("packer/right/"); TEST_ASSERT(packer_read_dir(ptr) == true, "An error happened"); @@ -271,6 +271,25 @@ TEST(packer_create_archive_1) { return TEST_SUCCESS; } +TEST(packer_create_archive_wrong_fn) { + packer_t *ptr; + + ptr = packer_init_dir("packer/right/"); + TEST_ASSERT(packer_read_dir(ptr) == true, "An error happened"); + TEST_ASSERT(packer_create_archive(ptr, "/non/sense/path") == false, + "Error did not raise"); + return TEST_SUCCESS; +} + +TEST(packer_create_archive_wrong_type) { + packer_t *ptr; + + ptr = packer_init_archive("test"); + TEST_ASSERT(packer_create_archive(ptr, "nocare") == false, + "Error did not raise") + return TEST_SUCCESS; +} + void register_test_packer(void) { reg_test("packer", packer_init_dir); reg_test("packer", packer_init_archive); @@ -302,5 +321,7 @@ void register_test_packer(void) { reg_test("packer", packer_header_comp_init); reg_test("packer", packer_header_deps_init); reg_test("packer", packer_create_archive_1); + reg_test("packer", packer_create_archive_wrong_fn); + reg_test("packer", packer_create_archive_wrong_type); }