2021-07-18 06:55:08 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
setUp() {
|
|
|
|
rm -f test.yml
|
|
|
|
}
|
|
|
|
|
|
|
|
testBasicEvalRoundTrip() {
|
2021-07-18 07:05:12 +00:00
|
|
|
./yq e -n ".a = 123" > test.yml
|
2021-07-18 06:55:08 +00:00
|
|
|
X=$(./yq e '.a' test.yml)
|
2021-07-18 07:05:12 +00:00
|
|
|
assertEquals 123 "$X"
|
2021-07-18 06:55:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
testBasicUpdateInPlaceSequence() {
|
|
|
|
cat >test.yml <<EOL
|
|
|
|
a: 0
|
|
|
|
EOL
|
|
|
|
./yq e -i ".a = 10" test.yml
|
|
|
|
X=$(./yq e '.a' test.yml)
|
2021-07-18 07:05:12 +00:00
|
|
|
assertEquals "10" "$X"
|
2021-07-18 06:55:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
testBasicUpdateInPlaceSequenceEvalAll() {
|
|
|
|
cat >test.yml <<EOL
|
|
|
|
a: 0
|
|
|
|
EOL
|
|
|
|
./yq ea -i ".a = 10" test.yml
|
|
|
|
X=$(./yq e '.a' test.yml)
|
2021-07-18 07:05:12 +00:00
|
|
|
assertEquals "10" "$X"
|
2021-07-18 06:55:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
testBasicNoExitStatus() {
|
|
|
|
echo "a: cat" > test.yml
|
|
|
|
X=$(./yq e '.z' test.yml)
|
2021-07-18 07:05:12 +00:00
|
|
|
assertEquals "null" "$X"
|
2021-07-18 06:55:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
testBasicExitStatus() {
|
|
|
|
echo "a: cat" > test.yml
|
|
|
|
X=$(./yq e -e '.z' test.yml 2&>/dev/null)
|
2021-07-18 07:05:12 +00:00
|
|
|
assertEquals 1 "$?"
|
2021-07-18 06:55:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
source ./scripts/shunit2
|