mirror of
https://github.com/mikefarah/yq.git
synced 2024-12-19 20:19:04 +00:00
Updated XML acceptance tests with proc inst and directives
This commit is contained in:
parent
e4b5769477
commit
86ef4e4d90
@ -127,6 +127,7 @@ testInputXmlNamespaces() {
|
|||||||
EOL
|
EOL
|
||||||
|
|
||||||
read -r -d '' expected << EOM
|
read -r -d '' expected << EOM
|
||||||
|
+p_xml: version="1.0"
|
||||||
map:
|
map:
|
||||||
+xmlns: some-namespace
|
+xmlns: some-namespace
|
||||||
+xmlns:xsi: some-instance
|
+xmlns:xsi: some-instance
|
||||||
@ -140,6 +141,26 @@ EOM
|
|||||||
assertEquals "$expected" "$X"
|
assertEquals "$expected" "$X"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
testInputXmlRoundtrip() {
|
||||||
|
cat >test.yml <<EOL
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<!DOCTYPE config SYSTEM "/etc/iwatch/iwatch.dtd" >
|
||||||
|
<map xmlns="some-namespace" xmlns:xsi="some-instance" xsi:schemaLocation="some-url">Meow</map>
|
||||||
|
EOL
|
||||||
|
|
||||||
|
read -r -d '' expected << EOM
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<!DOCTYPE config SYSTEM "/etc/iwatch/iwatch.dtd" >
|
||||||
|
<map xmlns="some-namespace" xmlns:xsi="some-instance" xsi:schemaLocation="some-url">Meow</map>
|
||||||
|
EOM
|
||||||
|
|
||||||
|
X=$(./yq -p=xml -o=xml test.yml)
|
||||||
|
assertEquals "$expected" "$X"
|
||||||
|
|
||||||
|
X=$(./yq ea -p=xml -o=xml test.yml)
|
||||||
|
assertEquals "$expected" "$X"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
testInputXmlStrict() {
|
testInputXmlStrict() {
|
||||||
cat >test.yml <<EOL
|
cat >test.yml <<EOL
|
||||||
@ -153,11 +174,11 @@ testInputXmlStrict() {
|
|||||||
</root>
|
</root>
|
||||||
EOL
|
EOL
|
||||||
|
|
||||||
X=$(./yq -p=xml --xml-strict-mode test.yml 2>&1)
|
X=$(./yq -p=xml --xml-strict-mode test.yml -o=xml 2>&1)
|
||||||
assertEquals 1 $?
|
assertEquals 1 $?
|
||||||
assertEquals "Error: bad file 'test.yml': XML syntax error on line 7: invalid character entity &writer;" "$X"
|
assertEquals "Error: bad file 'test.yml': XML syntax error on line 7: invalid character entity &writer;" "$X"
|
||||||
|
|
||||||
X=$(./yq ea -p=xml --xml-strict-mode test.yml 2>&1)
|
X=$(./yq ea -p=xml --xml-strict-mode test.yml -o=xml 2>&1)
|
||||||
assertEquals "Error: bad file 'test.yml': XML syntax error on line 7: invalid character entity &writer;" "$X"
|
assertEquals "Error: bad file 'test.yml': XML syntax error on line 7: invalid character entity &writer;" "$X"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user