* Added PRETTYPRINT_INDENT compile-time option controlling indentation level for XML,JSON and TEXT

* Default value is `3`
This commit is contained in:
Olof hagsand 2022-10-31 14:20:14 +01:00
parent 1830381249
commit 56f4bb45cc
11 changed files with 73 additions and 1152 deletions

View file

@ -2,8 +2,8 @@
# Autocli show tests
# Go through all formats and show for all formats
# Formats: XML, JSON, TEXT, CLI, NETCONF
# Pretty-print: false, true XXXX: align spaces
# API: cli_show_auto_mode(), cli_show_auto(), cli_show_config() XXX
# Pretty-print: false, true, indentation-level is 3 (see PRETTYPRINT_INDENT)
# API: cli_show_auto_mode(), cli_show_auto(), cli_show_config()
# Magic line must be first in script (see README.md)
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
@ -183,7 +183,7 @@ X='{"clixon-example:table":{"parameter":\[{"name":"x","value":"1","array1":\["a"
expectpart "$($clixon_cli -1 -f $cfg -l o show config $format)" 0 "^$X$"
new "cli check show config $format pretty-print"
expectpart "$($clixon_cli -1 -f $cfg -l o show config $format pretty-print)" 0 ' "clixon-example:table": {' --not-- ' "clixon-example:table": {'
expectpart "$($clixon_cli -1 -f $cfg -l o show config $format pretty-print)" 0 ' "clixon-example:table": {' --not-- ' "clixon-example:table": {'
new "cli check show config $format non-auto"
expectpart "$($clixon_cli -1 -f $cfg -l o show config $format config)" 0 "$X"
@ -211,7 +211,7 @@ new "cli check show config $format"
expectpart "$($clixon_cli -1 -f $cfg -l o show config $format)" 0 "clixon-example:table {" "parameter x {" "array1 \[" "parameter y {"
new "cli check show config $format pretty-print"
expectpart "$($clixon_cli -1 -f $cfg -l o show config $format pretty-print)" 0 " parameter x {" --not-- " parameter x {"
expectpart "$($clixon_cli -1 -f $cfg -l o show config $format pretty-print)" 0 " parameter x {" --not-- " parameter x {"
new "cli check show config $format non-auto"
expectpart "$($clixon_cli -1 -f $cfg -l o show config $format config)" 0 "clixon-example:table {" "parameter x {" "array1 \[" "parameter y {"

View file

@ -229,7 +229,7 @@ new "cli success validate"
expectpart "$($clixon_cli -1 -f $cfg -l o validate)" 0 "^$"
new "cli compare diff"
expectpart "$($clixon_cli -1 -f $cfg -l o show compare text)" 0 "+ address 1.2.3.4"
expectpart "$($clixon_cli -1 -f $cfg -l o show compare text)" 0 "+ address 1.2.3.4"
new "cli start shell"
expectpart "$($clixon_cli -1 -f $cfg -l o shell echo foo)" 0 "foo"

View file

@ -133,8 +133,8 @@ ret=$($clixon_cli -1 -f $cfg show config)
if [ $? -ne 0 ]; then
err 0 $r
fi
if [ "$ret" != "clixon-hello:hello world;" ]; then
err "clixon-hello:hello world;" "$ret"
if [ "$ret" != "clixon-hello:hello world;" ]; then
err "clixon-hello:hello world;" "$ret"
fi
new "netconf edit-config"

View file

@ -73,10 +73,10 @@ expecteofx "$clixon_util_json -j" 0 '{"a":[0,1,2,3]}' '{"a":"0"},{"a":"1"},{"a":
JSON='{"json:c":{"a":42,"s":"string"}}'
# Same with pretty-print
JSONP='{
"json:c": {
"a": 42,
"s": "string"
}
"json:c": {
"a": 42,
"s": "string"
}
}'
new "json no pp in/out"