1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-09-08 19:34:14 -04:00
profanity/tests/config/helpers.c

41 lines
991 B
C
Raw Normal View History

2014-01-19 11:32:31 -05:00
#include <setjmp.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdlib.h>
#include <cmocka.h>
2014-01-20 13:40:48 -05:00
#include <glib.h>
#include <stdio.h>
#include <unistd.h>
2014-01-19 11:32:31 -05:00
#include "common.h"
2014-01-20 13:40:48 -05:00
#include "config/preferences.h"
2014-01-19 11:32:31 -05:00
void init_preferences(void **state)
2014-01-19 11:32:31 -05:00
{
setenv("XDG_CONFIG_HOME", "./tests/files/xdg_config_home", 1);
gchar *xdg_config = xdg_get_config_home();
GString *profanity_dir = g_string_new(xdg_config);
g_string_append(profanity_dir, "/profanity");
if (!mkdir_recursive(profanity_dir->str)) {
assert_true(FALSE);
}
g_string_free(profanity_dir, TRUE);
2014-01-24 19:50:07 -05:00
FILE *f = fopen("./tests/files/xdg_config_home/profanity/profrc", "ab+");
if (f) {
g_free(xdg_config);
prefs_load();
}
2014-01-19 11:32:31 -05:00
}
void close_preferences(void **state)
2014-01-19 11:32:31 -05:00
{
2014-01-20 13:40:48 -05:00
prefs_close();
remove("./tests/files/xdg_config_home/profanity/profrc");
rmdir("./tests/files/xdg_config_home/profanity");
rmdir("./tests/files/xdg_config_home");
rmdir("./tests/files");
2014-01-19 11:32:31 -05:00
}