Updated to use -o for output format

This commit is contained in:
Mike Farah
2021-08-20 13:35:57 +10:00
parent 043e9128d7
commit 10d4eb3381
3 changed files with 69 additions and 2 deletions
+63
View File
@@ -0,0 +1,63 @@
#!/bin/bash
testOutputJsonDeprecated() {
cat >test.yml <<EOL
a: {b: ["cat"]}
EOL
read -r -d '' expected << EOM
{
"a": {
"b": [
"cat"
]
}
}
EOM
X=$(./yq e -j test.yml)
assertEquals "$expected" "$X"
X=$(./yq ea -j test.yml)
assertEquals "$expected" "$X"
}
testOutputJson() {
cat >test.yml <<EOL
a: {b: ["cat"]}
EOL
read -r -d '' expected << EOM
{
"a": {
"b": [
"cat"
]
}
}
EOM
X=$(./yq e -o=json test.yml)
assertEquals "$expected" "$X"
X=$(./yq ea -o=json test.yml)
assertEquals "$expected" "$X"
}
testOutputProperties() {
cat >test.yml <<EOL
a: {b: {c: ["cat"]}}
EOL
read -r -d '' expected << EOM
a.b.c.0 = cat
EOM
X=$(./yq e -o=props test.yml)
assertEquals "$expected" "$X"
X=$(./yq ea -o=props test.yml)
assertEquals "$expected" "$X"
}
source ./scripts/shunit2