Hash :
744cc03e
Author :
Date :
2012-10-30T12:10:36
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
#include "clar_libgit2.h"
#define TEST_FILE "config.refresh"
void test_config_refresh__initialize(void)
{
}
void test_config_refresh__cleanup(void)
{
cl_fixture_cleanup(TEST_FILE);
}
void test_config_refresh__update_value(void)
{
git_config *cfg;
int32_t v;
cl_git_mkfile(TEST_FILE, "[section]\n\tvalue = 1\n\n");
/* By freeing the config, we make sure we flush the values */
cl_git_pass(git_config_open_ondisk(&cfg, TEST_FILE));
cl_git_pass(git_config_get_int32(&v, cfg, "section.value"));
cl_assert_equal_i(1, v);
cl_git_rewritefile(TEST_FILE, "[section]\n\tvalue = 10\n\n");
cl_git_pass(git_config_get_int32(&v, cfg, "section.value"));
cl_assert_equal_i(1, v);
cl_git_pass(git_config_refresh(cfg));
cl_git_pass(git_config_get_int32(&v, cfg, "section.value"));
cl_assert_equal_i(10, v);
git_config_free(cfg);
}
void test_config_refresh__delete_value(void)
{
git_config *cfg;
int32_t v;
cl_git_mkfile(TEST_FILE, "[section]\n\tvalue = 1\n\n");
/* By freeing the config, we make sure we flush the values */
cl_git_pass(git_config_open_ondisk(&cfg, TEST_FILE));
cl_git_pass(git_config_get_int32(&v, cfg, "section.value"));
cl_assert_equal_i(1, v);
cl_git_fail(git_config_get_int32(&v, cfg, "section.newval"));
cl_git_rewritefile(TEST_FILE, "[section]\n\tnewval = 10\n\n");
cl_git_pass(git_config_get_int32(&v, cfg, "section.value"));
cl_assert_equal_i(1, v);
cl_git_fail(git_config_get_int32(&v, cfg, "section.newval"));
cl_git_pass(git_config_refresh(cfg));
cl_git_fail(git_config_get_int32(&v, cfg, "section.value"));
cl_git_pass(git_config_get_int32(&v, cfg, "section.newval"));
cl_assert_equal_i(10, v);
git_config_free(cfg);
}