From c24ff81c286698bf0cb4b80ba522b3ab7ee85de9 Mon Sep 17 00:00:00 2001 From: Yousong Zhou Date: Wed, 1 Apr 2015 20:44:22 +0800 Subject: [PATCH] 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 --- ...ta.result => cli.options.delta.commit.result} | 0 test/references/cli.options.delta.export.result | 5 +++++ test/tests.d/090_cli_options | 16 ++++++++++++---- 3 files changed, 17 insertions(+), 4 deletions(-) rename test/references/{options.delta.result => cli.options.delta.commit.result} (100%) create mode 100644 test/references/cli.options.delta.export.result diff --git a/test/references/options.delta.result b/test/references/cli.options.delta.commit.result similarity index 100% rename from test/references/options.delta.result rename to 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" -- 2.30.2