From cede78748291a8b5ae0dd0dc34c95da4a72fb3ea Mon Sep 17 00:00:00 2001
From: Ian Wienand <iwienand@redhat.com>
Date: Wed, 22 Jul 2015 13:36:12 +1000
Subject: [PATCH] Add file creation test

Ensure that iniadd is creating files that don't exist, as it has
historically done.

Change-Id: I2798996f3d46ff1dce410b815a87395f1bf729f9
---
 inc/ini-config           | 1 +
 tests/test_ini_config.sh | 5 +++++
 2 files changed, 6 insertions(+)

diff --git a/inc/ini-config b/inc/ini-config
index d23f4743f1..58386e2441 100644
--- a/inc/ini-config
+++ b/inc/ini-config
@@ -159,6 +159,7 @@ function inidelete {
 
 # Set an option in an INI file
 # iniset [-sudo] config-file section option value
+#  - if the file does not exist, it is created
 function iniset {
     local xtrace=$(set +o | grep xtrace)
     set +o xtrace
diff --git a/tests/test_ini_config.sh b/tests/test_ini_config.sh
index 61f2c410f9..d9cb8d8a99 100755
--- a/tests/test_ini_config.sh
+++ b/tests/test_ini_config.sh
@@ -199,6 +199,11 @@ for x in $del_cases; do
     fi
 done
 
+# test file-creation
+iniset $SUDO_ARG ${INI_TMP_ETC_DIR}/test.new.ini test foo bar
+VAL=$(iniget ${INI_TMP_ETC_DIR}/test.new.ini test foo)
+assert_equal "$VAL" "bar" "iniset created file"
+
 $SUDO rm -rf ${INI_TMP_DIR}
 
 report_results