summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYousong Zhou <yszhou4tech@gmail.com>2015-04-01 20:44:22 +0800
committerFelix Fietkau <nbd@openwrt.org>2015-04-03 20:41:40 +0200
commitc24ff81c286698bf0cb4b80ba522b3ab7ee85de9 (patch)
treecc9f0c29d4e4e173c43acb944acdfe890b922fa8
parent3c7f3556b0039a19ddd3e263286085f6896da0eb (diff)
downloaduci-c24ff81c286698bf0cb4b80ba522b3ab7ee85de9.tar.gz
tests: add test coverage for uci export with -P option.
- With "uci -P xxx/ export", changes in "xxx/" should be applied last. - With "uci -p xxx/ commit", changes in "xxx/" should be applied before ctx->savedir. Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
-rw-r--r--test/references/cli.options.delta.commit.result (renamed from test/references/options.delta.result)0
-rw-r--r--test/references/cli.options.delta.export.result5
-rw-r--r--test/tests.d/090_cli_options16
3 files changed, 17 insertions, 4 deletions
diff --git a/test/references/options.delta.result b/test/references/cli.options.delta.commit.result
index 3119b6f..3119b6f 100644
--- a/test/references/options.delta.result
+++ b/test/references/cli.options.delta.commit.result
diff --git a/test/references/cli.options.delta.export.result b/test/references/cli.options.delta.export.result
new file mode 100644
index 0000000..5aa71ce
--- /dev/null
+++ b/test/references/cli.options.delta.export.result
@@ -0,0 +1,5 @@
+package delta
+
+config sectype 'sec0'
+ list li0 '0'
+ list li0 '1'
diff --git a/test/tests.d/090_cli_options b/test/tests.d/090_cli_options
index 52052a3..55920a2 100644
--- a/test/tests.d/090_cli_options
+++ b/test/tests.d/090_cli_options
@@ -1,6 +1,7 @@
test_add_delta() {
local new_savedir="$TMP_DIR/new_savedir"
local config_delta="$CONFIG_DIR/delta"
+ local cmdoutput
# add normal changes
touch "$config_delta"
@@ -16,11 +17,18 @@ test_add_delta() {
assertEquals "delta.sec0='sectype'
delta.sec0.li0+='0'" "$($UCI changes)"
- # check combined changes. order matters here.
+ # check combined changes. Order matters here.
+ cmdoutput="$($UCI -P "$new_savedir" changes)"
+ assertTrue "$?"
assertEquals "delta.sec0='sectype'
-delta.sec0.li0+='1'
+delta.sec0.li0+='0'
delta.sec0='sectype'
-delta.sec0.li0+='0'" "$($UCI -P "$new_savedir" changes)"
+delta.sec0.li0+='1'" "$cmdoutput"
+
+ # check combined export. Order matters here.
+ cmdoutput="$($UCI -P "$new_savedir" export)"
+ assertTrue "$?"
+ assertEquals "$(cat $REF_DIR/cli.options.delta.export.result)" "$cmdoutput"
# check CLI_FLAG_NOCOMMIT with -P option.
$UCI -P "$new_savedir" commit
@@ -30,7 +38,7 @@ delta.sec0.li0+='0'" "$($UCI -P "$new_savedir" changes)"
# check normal commit.
$UCI -p "$new_savedir" commit
assertTrue "$?"
- assertSameFile "$REF_DIR/options.delta.result" "$config_delta"
+ assertSameFile "$REF_DIR/cli.options.delta.commit.result" "$config_delta"
rm -rf "$new_savedir"
rm -f "$config_delta"