diff options
author | Carlos Martín Nieto <cmn@elego.de> | 2011-06-28 17:21:44 +0400 |
---|---|---|
committer | Vicent Marti <tanoku@gmail.com> | 2011-07-05 04:32:17 +0400 |
commit | 2601fcfc1e1c22874d266dc7086532fa52f44dd5 (patch) | |
tree | bf3b3d7318575b1f528b2f475bc1b5c77bfa2ee1 /tests | |
parent | 6d4b609718ad7ef7211974624a06564f15610a8b (diff) |
Add tests for deleting a config var
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/resources/config/config9 | 1 | ||||
-rw-r--r-- | tests/t15-config.c | 30 |
2 files changed, 31 insertions, 0 deletions
diff --git a/tests/resources/config/config9 b/tests/resources/config/config9 index 4359c7826..34fdc07a5 100644 --- a/tests/resources/config/config9 +++ b/tests/resources/config/config9 @@ -1,2 +1,3 @@ [core] + dummy2 = 42 dummy = 1 diff --git a/tests/t15-config.c b/tests/t15-config.c index 63fe8e100..25cdcbd65 100644 --- a/tests/t15-config.c +++ b/tests/t15-config.c @@ -235,6 +235,34 @@ BEGIN_TEST(config11, "fall back to the global config") git_repository_free(repo); END_TEST +BEGIN_TEST(config12, "delete a value") + git_config *cfg; + int i; + + /* By freeing the config, we make sure we flush the values */ + must_pass(git_config_open_ondisk(&cfg, CONFIG_BASE "/config9")); + must_pass(git_config_set_int(cfg, "core.dummy", 5)); + git_config_free(cfg); + + must_pass(git_config_open_ondisk(&cfg, CONFIG_BASE "/config9")); + must_pass(git_config_del(cfg, "core.dummy")); + git_config_free(cfg); + + must_pass(git_config_open_ondisk(&cfg, CONFIG_BASE "/config9")); + must_be_true(git_config_get_int(cfg, "core.dummy", &i) == GIT_ENOTFOUND); + must_pass(git_config_set_int(cfg, "core.dummy", 1)); + git_config_free(cfg); +END_TEST + +BEGIN_TEST(config13, "can't delete a non-existent value") + git_config *cfg; + + /* By freeing the config, we make sure we flush the values */ + must_pass(git_config_open_ondisk(&cfg, CONFIG_BASE "/config9")); + must_be_true(git_config_del(cfg, "core.imaginary") == GIT_ENOTFOUND); + git_config_free(cfg); +END_TEST + BEGIN_SUITE(config) ADD_TEST(config0); ADD_TEST(config1); @@ -248,4 +276,6 @@ BEGIN_SUITE(config) ADD_TEST(config9); ADD_TEST(config10); ADD_TEST(config11); + ADD_TEST(config12); + ADD_TEST(config13); END_SUITE |