[OpenWrt-Devel] [PATCH v2 10/16] tests: add test coverage for uci list related commands.

Yousong Zhou yszhou4tech at gmail.com
Tue Dec 16 02:00:12 EST 2014


Signed-off-by: Yousong Zhou <yszhou4tech at gmail.com>
---
 test/references/add_list_changes.result          |    4 ++
 test/references/add_list_config.result           |    6 +++
 test/references/add_list_show.result             |    3 ++
 test/references/del_list_config.result           |    5 +++
 test/references/del_list_multiline_config.result |    4 ++
 test/tests.d/080_list                            |   52 ++++++++++++++++++++++
 6 files changed, 74 insertions(+)
 create mode 100644 test/references/add_list_changes.result
 create mode 100644 test/references/add_list_config.result
 create mode 100644 test/references/add_list_show.result
 create mode 100644 test/references/del_list_config.result
 create mode 100644 test/references/del_list_multiline_config.result
 create mode 100644 test/tests.d/080_list

diff --git a/test/references/add_list_changes.result b/test/references/add_list_changes.result
new file mode 100644
index 0000000..78e78b6
--- /dev/null
+++ b/test/references/add_list_changes.result
@@ -0,0 +1,4 @@
+list_test_config.SEC0='section'
+list_test_config.SEC0.list0+='value0'
+list_test_config.SEC0.list0+='"Hello
+, world"'
diff --git a/test/references/add_list_config.result b/test/references/add_list_config.result
new file mode 100644
index 0000000..679cccc
--- /dev/null
+++ b/test/references/add_list_config.result
@@ -0,0 +1,6 @@
+
+config section 'SEC0'
+	list list0 'value0'
+	list list0 '"Hello
+, world"'
+
diff --git a/test/references/add_list_show.result b/test/references/add_list_show.result
new file mode 100644
index 0000000..3dd83cd
--- /dev/null
+++ b/test/references/add_list_show.result
@@ -0,0 +1,3 @@
+list_test_config.SEC0=section
+list_test_config.SEC0.list0='value0' '"Hello
+, world"'
diff --git a/test/references/del_list_config.result b/test/references/del_list_config.result
new file mode 100644
index 0000000..8e66bbb
--- /dev/null
+++ b/test/references/del_list_config.result
@@ -0,0 +1,5 @@
+
+config section 'SEC0'
+	list list0 '"Hello
+, world"'
+
diff --git a/test/references/del_list_multiline_config.result b/test/references/del_list_multiline_config.result
new file mode 100644
index 0000000..fe67784
--- /dev/null
+++ b/test/references/del_list_multiline_config.result
@@ -0,0 +1,4 @@
+
+config section 'SEC0'
+	list list0 'value0'
+
diff --git a/test/tests.d/080_list b/test/tests.d/080_list
new file mode 100644
index 0000000..e0a910a
--- /dev/null
+++ b/test/tests.d/080_list
@@ -0,0 +1,52 @@
+prepare_list_test() {
+	touch ${CONFIG_DIR}/list_test_config
+	${UCI} set list_test_config.SEC0=section
+	${UCI} add_list list_test_config.SEC0.list0=value0
+	${UCI} add_list list_test_config.SEC0.list0='"Hello
+,'" world\""
+}
+test_add_list_config() {
+	prepare_list_test
+	${UCI} commit
+	assertSameFile "${REF_DIR}/add_list_config.result" "$CONFIG_DIR/list_test_config"
+}
+
+test_add_list_get() {
+	# To maintain compatibility with current code, do not quote
+	# list values that do not contain blank spaces ("\x20\t\r\n") within it.
+	prepare_list_test
+	value_list_get=$(${UCI} get list_test_config.SEC0.list0)
+	assertEquals "$value_list_get" "value0 '\"Hello
+, world\"'"
+}
+
+test_add_list_show() {
+	prepare_list_test
+	value_list_show=$(${UCI} show list_test_config)
+	value_list_show_ref=$(cat "$REF_DIR/add_list_show.result")
+	assertEquals "$value_list_show" "$value_list_show_ref"
+}
+
+test_add_list_changes() {
+	prepare_list_test
+	value_list_changes=$(${UCI} changes)
+	value_list_changes_ref=$(cat "$REF_DIR/add_list_changes.result")
+	assertEquals "$value_list_changes" "$value_list_changes_ref"
+}
+
+test_del_list() {
+	prepare_list_test
+	${UCI} commit
+	${UCI} del_list list_test_config.SEC0.list0=value0
+	${UCI} commit
+	assertSameFile "${REF_DIR}/del_list_config.result" "$CONFIG_DIR/list_test_config"
+}
+
+test_del_list_multiline() {
+	prepare_list_test
+	${UCI} commit
+	${UCI} del_list list_test_config.SEC0.list0='"Hello
+,'' world"'
+	${UCI} commit
+	assertSameFile "${REF_DIR}/del_list_multiline_config.result" "$CONFIG_DIR/list_test_config"
+}
-- 
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