summaryrefslogtreecommitdiff
path: root/tests/test-config.sh
diff options
context:
space:
mode:
authorMatthew Leeds <matthew.leeds@endlessm.com>2018-09-28 15:36:49 -0700
committerAtomic Bot <atomic-devel@projectatomic.io>2019-03-01 16:29:44 +0000
commiteecd989d4661f48c51f49565422ef11d1c231371 (patch)
tree9e21e4c80575164e6aa33951c855d8c9c0a8d40e /tests/test-config.sh
parent77f91d6c6be2d264aa14be9d33c0488dc7e141cc (diff)
downloadostree-eecd989d4661f48c51f49565422ef11d1c231371.tar.gz
ostree/config: Add an "unset" operation
Currently there's a way to set a key to the empty string but there's no way to unset it completely (remove the key from the group). This might be helpful for instance if you want to temporarily set "core.lock-timeout-secs" to a specific value for the duration of one operation and then return it to the default after that operation completes. This commit implements an "unset" operation for the config command, adds a unit test, and updates the man page. Closes: #1743 Approved by: cgwalters
Diffstat (limited to 'tests/test-config.sh')
-rwxr-xr-xtests/test-config.sh26
1 files changed, 25 insertions, 1 deletions
diff --git a/tests/test-config.sh b/tests/test-config.sh
index b1ea3e5e..62f63006 100755
--- a/tests/test-config.sh
+++ b/tests/test-config.sh
@@ -23,7 +23,7 @@ set -euo pipefail
. $(dirname $0)/libtest.sh
-echo '1..2'
+echo '1..3'
ostree_repo_init repo
${CMD_PREFIX} ostree remote add --repo=repo --set=xa.title=Flathub --set=xa.title-is-set=true flathub https://dl.flathub.org/repo/
@@ -53,3 +53,27 @@ assert_file_has_content repo/config "Nightly Flathub"
assert_file_has_content repo/config "false"
assert_file_has_content repo/config "http://example.com/ostree/"
echo "ok config set"
+
+# Check that "ostree config unset" works
+${CMD_PREFIX} ostree config --repo=repo set core.lock-timeout-secs 60
+assert_file_has_content repo/config "lock-timeout-secs=60"
+${CMD_PREFIX} ostree config --repo=repo unset core.lock-timeout-secs
+assert_not_file_has_content repo/config "lock-timeout-secs="
+
+# Check that "ostree config get" errors out on the key
+if ${CMD_PREFIX} ostree config --repo=repo get core.lock-timeout-secs 2>err.txt; then
+ assert_not_reached "ostree config get should not work after unsetting a key"
+fi
+assert_file_has_content err.txt "error: Key file does not have key “lock-timeout-secs” in group “core”"
+
+# Check that it's idempotent
+${CMD_PREFIX} ostree config --repo=repo unset core.lock-timeout-secs
+assert_not_file_has_content repo/config "lock-timeout-secs="
+
+# Check that the group doesn't need to exist
+${CMD_PREFIX} ostree config --repo=repo unset --group='remote "aoeuhtns"' 'xa.title'
+
+# Check that the key doesn't need to exist
+${CMD_PREFIX} ostree config --repo=repo set --group='remote "aoeuhtns"' 'xa.title-is-set' 'false'
+${CMD_PREFIX} ostree config --repo=repo unset --group='remote "aoeuhtns"' 'xa.title'
+echo "ok config unset"