[OpenWrt-Devel] [PATCH 1/2] tests: add test coverage for uci export with -P option.
Yousong Zhou
yszhou4tech at gmail.com
Wed Apr 1 08:44:22 EDT 2015
- 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 at gmail.com>
---
test/references/cli.options.delta.commit.result | 5 +++++
test/references/cli.options.delta.export.result | 5 +++++
test/references/options.delta.result | 5 -----
test/tests.d/090_cli_options | 16 ++++++++++++----
4 files changed, 22 insertions(+), 9 deletions(-)
create mode 100644 test/references/cli.options.delta.commit.result
create mode 100644 test/references/cli.options.delta.export.result
delete mode 100644 test/references/options.delta.result
diff --git a/test/references/cli.options.delta.commit.result b/test/references/cli.options.delta.commit.result
new file mode 100644
index 0000000..3119b6f
--- /dev/null
+++ b/test/references/cli.options.delta.commit.result
@@ -0,0 +1,5 @@
+
+config sectype 'sec0'
+ list li0 '1'
+ list li0 '0'
+
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/references/options.delta.result b/test/references/options.delta.result
deleted file mode 100644
index 3119b6f..0000000
--- a/test/references/options.delta.result
+++ /dev/null
@@ -1,5 +0,0 @@
-
-config sectype 'sec0'
- list li0 '1'
- list li0 '0'
-
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"
--
1.7.10.4
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list