mirror of
https://gitee.com/mirrors_adrian-thurston/yq.git
synced 2026-01-15 07:53:35 +08:00
44 lines
757 B
Bash
Executable File
44 lines
757 B
Bash
Executable File
#!/bin/bash
|
|
|
|
setUp() {
|
|
rm -f test.yml
|
|
}
|
|
|
|
testBasicEvalRoundTrip() {
|
|
random=$((1 + $RANDOM % 10))
|
|
./yq e -n ".a = $random" > test.yml
|
|
X=$(./yq e '.a' test.yml)
|
|
assertEquals $random $X
|
|
}
|
|
|
|
testBasicUpdateInPlaceSequence() {
|
|
cat >test.yml <<EOL
|
|
a: 0
|
|
EOL
|
|
./yq e -i ".a = 10" test.yml
|
|
X=$(./yq e '.a' test.yml)
|
|
assertEquals "10" $X
|
|
}
|
|
|
|
testBasicUpdateInPlaceSequenceEvalAll() {
|
|
cat >test.yml <<EOL
|
|
a: 0
|
|
EOL
|
|
./yq ea -i ".a = 10" test.yml
|
|
X=$(./yq e '.a' test.yml)
|
|
assertEquals "10" $X
|
|
}
|
|
|
|
testBasicNoExitStatus() {
|
|
echo "a: cat" > test.yml
|
|
X=$(./yq e '.z' test.yml)
|
|
assertEquals "null" $X
|
|
}
|
|
|
|
testBasicExitStatus() {
|
|
echo "a: cat" > test.yml
|
|
X=$(./yq e -e '.z' test.yml 2&>/dev/null)
|
|
assertEquals 1 $?
|
|
}
|
|
|
|
source ./scripts/shunit2 |