Added more tests

This commit is contained in:
Mike Farah 2021-07-19 20:18:42 +10:00
parent dafa114e65
commit 38dd4175fb
1 changed files with 59 additions and 1 deletions

View File

@ -13,6 +13,8 @@ testLeadingSeperatorWithDoc() {
# cool # cool
--- ---
a: test a: test
---
b: cool
EOL EOL
read -r -d '' expected << EOM read -r -d '' expected << EOM
@ -20,9 +22,11 @@ EOL
# cool # cool
--- ---
a: thing a: thing
---
b: cool
EOM EOM
X=$(./yq e '.a = "thing"' - < test.yml) X=$(./yq e '(select(di == 0) | .a) = "thing"' - < test.yml)
assertEquals "$expected" "$X" assertEquals "$expected" "$X"
} }
@ -80,6 +84,20 @@ EOL
assertEquals "$expected" "$X" 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() { testLeadingSeperatorMultiDocEvalComments() {
cat >test.yml <<EOL cat >test.yml <<EOL
# hi peeps # hi peeps
@ -140,6 +158,46 @@ EOM
assertEquals "$expected" "$X" 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() { testLeadingSeperatorMultiDocEvalCommentsLeadingSep() {
cat >test.yml <<EOL cat >test.yml <<EOL
--- ---