tests: add test coverage for uci export with -P option.
authorYousong Zhou <yszhou4tech@gmail.com>
Wed, 1 Apr 2015 12:44:22 +0000 (20:44 +0800)
committerFelix Fietkau <nbd@openwrt.org>
Fri, 3 Apr 2015 18:41:40 +0000 (20:41 +0200)
 - 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>
test/references/cli.options.delta.commit.result [new file with mode: 0644]
test/references/cli.options.delta.export.result [new file with mode: 0644]
test/references/options.delta.result [deleted file]
test/tests.d/090_cli_options

diff --git a/test/references/cli.options.delta.commit.result b/test/references/cli.options.delta.commit.result
new file mode 100644 (file)
index 0000000..3119b6f
--- /dev/null
@@ -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 (file)
index 0000000..5aa71ce
--- /dev/null
@@ -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 (file)
index 3119b6f..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-
-config sectype 'sec0'
-       list li0 '1'
-       list li0 '0'
-
index 52052a3fa1de52b95ec11ac47a642c99490bbf58..55920a2af85856070f3bfa30d01d749182b76905 100644 (file)
@@ -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"