Specify mock config file content in test. Instead of using a config file in resources, include the config file content to be tested directly in the test.
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
diff --git a/tests/config/write.c b/tests/config/write.c
index 6318c49..bcc8757 100644
--- a/tests/config/write.c
+++ b/tests/config/write.c
@@ -6,7 +6,6 @@ void test_config_write__initialize(void)
cl_fixture_sandbox("config/config9");
cl_fixture_sandbox("config/config15");
cl_fixture_sandbox("config/config17");
- cl_fixture_sandbox("config/config21");
}
void test_config_write__cleanup(void)
@@ -14,7 +13,6 @@ void test_config_write__cleanup(void)
cl_fixture_cleanup("config9");
cl_fixture_cleanup("config15");
cl_fixture_cleanup("config17");
- cl_fixture_cleanup("config21");
}
void test_config_write__replace_value(void)
@@ -114,12 +112,21 @@ void test_config_write__delete_value_at_specific_level(void)
*/
void test_config_write__delete_value_with_duplicate_header(void)
{
- const char *file_name = "config21";
+ const char *file_name = "config-duplicate-header";
const char *entry_name = "remote.origin.url";
git_config *cfg;
git_config_entry *entry;
- /* Make sure the expected entry exists */
+ /* This config can occur after removing and re-adding the origin remote */
+ const char *file_content =
+ "[remote \"origin\"]\n" \
+ "[branch \"master\"]\n" \
+ " remote = \"origin\"\n" \
+ "[remote \"origin\"]\n" \
+ " url = \"foo\"\n";
+
+ /* Write the test config and make sure the expected entry exists */
+ cl_git_mkfile(file_name, file_content);
cl_git_pass(git_config_open_ondisk(&cfg, file_name));
cl_git_pass(git_config_get_entry(&entry, cfg, entry_name));
diff --git a/tests/resources/config/config21 b/tests/resources/config/config21
deleted file mode 100644
index a63b52f..0000000
--- a/tests/resources/config/config21
+++ /dev/null
@@ -1,6 +0,0 @@
-# This configuration can occur after removing and re-adding the origin remote
-[remote "origin"]
-[branch "master"]
- remote = "origin"
-[remote "origin"]
- url = "foo"