Added more tests

This commit is contained in:
Mike Farah 2021-07-19 20:18:42 +10:00
parent dafa114e65
commit 38dd4175fb

View File

@ -13,6 +13,8 @@ testLeadingSeperatorWithDoc() {
# cool
---
a: test
---
b: cool
EOL
read -r -d '' expected << EOM
@ -20,9 +22,11 @@ EOL
# cool
---
a: thing
---
b: cool
EOM
X=$(./yq e '.a = "thing"' - < test.yml)
X=$(./yq e '(select(di == 0) | .a) = "thing"' - < test.yml)
assertEquals "$expected" "$X"
}
@ -80,6 +84,20 @@ EOL
assertEquals "$expected" "$X"
}
testLeadingSeperatorMultiDocInOneFileEvalAll() {
cat >test.yml <<EOL
---
# hi peeps
# cool
a: test
---
b: things
EOL
expected=$(cat test.yml)
X=$(./yq ea '.' test.yml)
assertEquals "$expected" "$X"
}
testLeadingSeperatorMultiDocEvalComments() {
cat >test.yml <<EOL
# hi peeps
@ -140,6 +158,46 @@ EOM
assertEquals "$expected" "$X"
}
testLeadingSeperatorMultiMultiDocEvalCommentsTrailingSep() {
cat >test.yml <<EOL
# hi peeps
# cool
---
a: test
---
a1: test2
EOL
cat >test2.yml <<EOL
# this is another doc
# great
---
b: sane
---
b2: cool
EOL
read -r -d '' expected << EOM
# hi peeps
# cool
---
a: test
---
a1: test2
---
# this is another doc
# great
---
b: sane
---
b2: cool
EOM
X=$(./yq e '.' test.yml test2.yml)
assertEquals "$expected" "$X"
}
testLeadingSeperatorMultiDocEvalCommentsLeadingSep() {
cat >test.yml <<EOL
---