summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYousong Zhou <yszhou4tech@gmail.com>2014-12-16 15:00:09 +0800
committerFelix Fietkau <nbd@openwrt.org>2014-12-18 12:38:15 +0100
commit8dd9e03ef277f0078b1a75e6c7d82e9d42f35c2f (patch)
tree75c5fcdea40355ba0a7360865bf6ae57467d5229
parent5086ffb40bd77dd14ce78534b38a86fe371aadb8 (diff)
downloaduci-8dd9e03ef277f0078b1a75e6c7d82e9d42f35c2f.tar.gz
tests: add more test coverage for `uci show' command.
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
-rw-r--r--test/references/show_parsing_multiline.data20
-rw-r--r--test/references/show_parsing_multiline_option.result12
-rw-r--r--test/references/show_parsing_multiline_package.result18
-rw-r--r--test/references/show_parsing_multiline_section.result16
-rw-r--r--test/tests.d/050_show31
5 files changed, 97 insertions, 0 deletions
diff --git a/test/references/show_parsing_multiline.data b/test/references/show_parsing_multiline.data
new file mode 100644
index 0000000..670e809
--- /dev/null
+++ b/test/references/show_parsing_multiline.data
@@ -0,0 +1,20 @@
+config main
+ option version 1.4.1
+
+config sockd 'instance0'
+ option enabled 1
+ list internal_network vpn
+ list external_network wan
+
+ option extra_config '
+ user.unprivileged: nobody
+ client pass {
+ from: 0.0.0.0/0 to: 0.0.0.0/0
+ session.max: 64
+ log: error
+ }
+
+ socks pass {
+ from: 0.0.0.0/0 to: 0.0.0.0/0
+ log: connect
+ } '
diff --git a/test/references/show_parsing_multiline_option.result b/test/references/show_parsing_multiline_option.result
new file mode 100644
index 0000000..6f7aacf
--- /dev/null
+++ b/test/references/show_parsing_multiline_option.result
@@ -0,0 +1,12 @@
+sockd.instance0.extra_config='
+ user.unprivileged: nobody
+ client pass {
+ from: 0.0.0.0/0 to: 0.0.0.0/0
+ session.max: 64
+ log: error
+ }
+
+ socks pass {
+ from: 0.0.0.0/0 to: 0.0.0.0/0
+ log: connect
+ } '
diff --git a/test/references/show_parsing_multiline_package.result b/test/references/show_parsing_multiline_package.result
new file mode 100644
index 0000000..218082d
--- /dev/null
+++ b/test/references/show_parsing_multiline_package.result
@@ -0,0 +1,18 @@
+sockd.@main[0]=main
+sockd.@main[0].version='1.4.1'
+sockd.instance0=sockd
+sockd.instance0.enabled='1'
+sockd.instance0.internal_network='vpn'
+sockd.instance0.external_network='wan'
+sockd.instance0.extra_config='
+ user.unprivileged: nobody
+ client pass {
+ from: 0.0.0.0/0 to: 0.0.0.0/0
+ session.max: 64
+ log: error
+ }
+
+ socks pass {
+ from: 0.0.0.0/0 to: 0.0.0.0/0
+ log: connect
+ } '
diff --git a/test/references/show_parsing_multiline_section.result b/test/references/show_parsing_multiline_section.result
new file mode 100644
index 0000000..0506ac3
--- /dev/null
+++ b/test/references/show_parsing_multiline_section.result
@@ -0,0 +1,16 @@
+sockd.instance0=sockd
+sockd.instance0.enabled='1'
+sockd.instance0.internal_network='vpn'
+sockd.instance0.external_network='wan'
+sockd.instance0.extra_config='
+ user.unprivileged: nobody
+ client pass {
+ from: 0.0.0.0/0 to: 0.0.0.0/0
+ session.max: 64
+ log: error
+ }
+
+ socks pass {
+ from: 0.0.0.0/0 to: 0.0.0.0/0
+ log: connect
+ } '
diff --git a/test/tests.d/050_show b/test/tests.d/050_show
index 7d7e160..ce0eafc 100644
--- a/test/tests.d/050_show
+++ b/test/tests.d/050_show
@@ -9,3 +9,34 @@ test_get_parsing()
assertFailWithNoReturn "${UCI_Q} show test.section.opt.val.qsdf.qsd"
assertFailWithNoReturn "${UCI_Q} show test.section.opt.valqsqsd"
}
+
+prepare_get_parsing_multiline() {
+ cp ${REF_DIR}/show_parsing_multiline.data ${CONFIG_DIR}/sockd
+}
+
+test_get_parsing_multiline_package()
+{
+ prepare_get_parsing_multiline
+
+ value=$(${UCI_Q} show sockd)
+ value_ref=$(cat ${REF_DIR}/show_parsing_multiline_package.result)
+ assertEquals "$value_ref" "$value"
+}
+
+test_get_parsing_multiline_section()
+{
+ prepare_get_parsing_multiline
+
+ value=$(${UCI_Q} show sockd.instance0)
+ value_ref=$(cat ${REF_DIR}/show_parsing_multiline_section.result)
+ assertEquals "$value_ref" "$value"
+}
+
+test_get_parsing_multiline_option()
+{
+ prepare_get_parsing_multiline
+
+ value=$(${UCI_Q} show sockd.instance0.extra_config)
+ value_ref=$(cat ${REF_DIR}/show_parsing_multiline_option.result)
+ assertEquals "$value_ref" "$value"
+}