mirror of
https://github.com/mikefarah/yq.git
synced 2024-12-19 20:19:04 +00:00
a9c3617b4f
* Decoder Properties * Added properties round trip test * Fixed property decode for github actions * Refactored XML test to use common functions * Switched formatScenario parameter order for more readablity
79 lines
1.3 KiB
Bash
Executable File
79 lines
1.3 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
setUp() {
|
|
rm test*.yml 2>/dev/null || true
|
|
rm test*.properties 2>/dev/null || true
|
|
rm test*.xml 2>/dev/null || true
|
|
}
|
|
|
|
testInputProperties() {
|
|
cat >test.properties <<EOL
|
|
mike.things = hello
|
|
EOL
|
|
|
|
read -r -d '' expected << EOM
|
|
mike:
|
|
things: hello
|
|
EOM
|
|
|
|
X=$(./yq e -p=props test.properties)
|
|
assertEquals "$expected" "$X"
|
|
|
|
X=$(./yq ea -p=props test.properties)
|
|
assertEquals "$expected" "$X"
|
|
}
|
|
|
|
testInputPropertiesGitHubAction() {
|
|
cat >test.properties <<EOL
|
|
mike.things = hello
|
|
EOL
|
|
|
|
read -r -d '' expected << EOM
|
|
mike:
|
|
things: hello
|
|
EOM
|
|
|
|
X=$(cat /dev/null | ./yq e -p=props test.properties)
|
|
assertEquals "$expected" "$X"
|
|
|
|
X=$(cat /dev/null | ./yq ea -p=props test.properties)
|
|
assertEquals "$expected" "$X"
|
|
}
|
|
|
|
testInputXml() {
|
|
cat >test.yml <<EOL
|
|
<cat legs="4">BiBi</cat>
|
|
EOL
|
|
|
|
read -r -d '' expected << EOM
|
|
cat:
|
|
+content: BiBi
|
|
+legs: "4"
|
|
EOM
|
|
|
|
X=$(./yq e -p=xml test.yml)
|
|
assertEquals "$expected" "$X"
|
|
|
|
X=$(./yq ea -p=xml test.yml)
|
|
assertEquals "$expected" "$X"
|
|
}
|
|
|
|
testInputXmlGithubAction() {
|
|
cat >test.yml <<EOL
|
|
<cat legs="4">BiBi</cat>
|
|
EOL
|
|
|
|
read -r -d '' expected << EOM
|
|
cat:
|
|
+content: BiBi
|
|
+legs: "4"
|
|
EOM
|
|
|
|
X=$(cat /dev/null | ./yq e -p=xml test.yml)
|
|
assertEquals "$expected" "$X"
|
|
|
|
X=$(cat /dev/null | ./yq ea -p=xml test.yml)
|
|
assertEquals "$expected" "$X"
|
|
}
|
|
|
|
source ./scripts/shunit2 |