diff options
author | Patrick Steinhardt <ps@pks.im> | 2019-11-06 07:27:35 +0100 |
---|---|---|
committer | Patrick Steinhardt <ps@pks.im> | 2019-11-06 07:29:13 +0100 |
commit | 146e5bf7b1740c0881057d1ca0233ca0852451ab (patch) | |
tree | 140489cbf1a8265510ee5c06df19074acc5e7be0 /tests/config | |
parent | 5d773a1833ef6d0fb2093e00b1cf9bfb668a1ffc (diff) | |
download | libgit2-146e5bf7b1740c0881057d1ca0233ca0852451ab.tar.gz |
config_mem: implement support for snapshots
Similar as in commit dadbb33b6 (Fix crash if snapshotting a
config_snapshot, 2019-11-01), let's implement snapshots for in-memory
configuration entries. As this deletes more code than it adds, it
doesn't make any sense to not allow for this and allows users to treat
config backends mostly the same.
Diffstat (limited to 'tests/config')
-rw-r--r-- | tests/config/snapshot.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/config/snapshot.c b/tests/config/snapshot.c index 3b90cfe49..5cc08a721 100644 --- a/tests/config/snapshot.c +++ b/tests/config/snapshot.c @@ -1,5 +1,7 @@ #include "clar_libgit2.h" +#include "config_backend.h" + static git_config *cfg; static git_config *snapshot; @@ -120,3 +122,18 @@ void test_config_snapshot__snapshot(void) cl_git_pass(p_unlink("configfile")); } + +void test_config_snapshot__snapshot_from_in_memony(void) +{ + const char *configuration = "[section]\nkey = 1\n"; + git_config_backend *backend; + int i; + + cl_git_pass(git_config_new(&cfg)); + cl_git_pass(git_config_backend_from_string(&backend, configuration, strlen(configuration))); + cl_git_pass(git_config_add_backend(cfg, backend, 0, NULL, 0)); + + cl_git_pass(git_config_snapshot(&snapshot, cfg)); + cl_git_pass(git_config_get_int32(&i, snapshot, "section.key")); + cl_assert_equal_i(i, 1); +} |