Fix tests and MIME attachments

This commit is contained in:
Konstantin Nazarov 2023-10-01 15:22:44 +01:00
parent e279f66801
commit 87c286d5b1
Signed by: knazarov
GPG key ID: 4CFE0A42FA409C22
2 changed files with 27 additions and 27 deletions

View file

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
# #
# Distributed under the terms of the BSD License # Distributed under the terms of the BSD License
# #
@ -121,7 +121,7 @@ get_headers() {
FILTER="\ FILTER="\
{ \ { \
if (\$0~/^$/) {exit} \ if (\$0~/^$/) {exit} \
if (\$0!~/^[^ ]*: .*$/) {exit} \ if (\$0!~/^[^ ]*:.*$/) {exit} \
print \$0 \ print \$0 \
} \ } \
" "
@ -276,7 +276,7 @@ pack_part() {
echo "Content-Type: $CONTENT_TYPE" echo "Content-Type: $CONTENT_TYPE"
echo "Content-Transfer-Encoding: base64" echo "Content-Transfer-Encoding: base64"
echo echo
base64 | fold -w 76 < "$PART_FILE" base64 < "$PART_FILE" | fold -w 76
fi fi
} }

16
test.sh
View file

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
# #
# Distributed under the terms of the BSD License # Distributed under the terms of the BSD License
# #
@ -63,8 +63,8 @@ assert() {
result="$(eval 2>/dev/null $1 <<< ${3:-})" || true result="$(eval 2>/dev/null $1 <<< ${3:-})" || true
if [[ "$result" == "$expected" ]]; then if [[ "$result" == "$expected" ]]; then
return return
fi fi
result="$(sed -e :a -e '$!N;s/\n/\\n/;ta' <<< "$result")" result="$(sed -e :a -e '$!N;s/\n/\\n/;ta' <<< "$result")"
echo "Expected '$command' == '$expected'. Got: '$result'" echo "Expected '$command' == '$expected'. Got: '$result'"
@ -169,7 +169,7 @@ edit_note() {
NOTE_ID="$(cat "$(pwd)/notes/cur"/* | grep X-Note-Id | cut -d ' ' -f 2)" NOTE_ID="$(cat "$(pwd)/notes/cur"/* | grep X-Note-Id | cut -d ' ' -f 2)"
cat > "$(pwd)/editor.sh" <<- EOF cat > "$(pwd)/editor.sh" <<- EOF
#!/bin/bash #!/usr/bin/env bash
FILENAME="\$1" FILENAME="\$1"
echo "line2" >> "\$FILENAME" echo "line2" >> "\$FILENAME"
EOF EOF
@ -192,7 +192,7 @@ edit_note_add_file() {
NOTE_ID="$(cat "$(pwd)/notes/cur"/* | grep X-Note-Id | cut -d ' ' -f 2)" NOTE_ID="$(cat "$(pwd)/notes/cur"/* | grep X-Note-Id | cut -d ' ' -f 2)"
cat > "$(pwd)/editor.sh" <<- EOF cat > "$(pwd)/editor.sh" <<- EOF
#!/bin/bash #!/usr/bin/env bash
FILENAME="\$1" FILENAME="\$1"
echo "newfile" > "\$FILENAME.txt" echo "newfile" > "\$FILENAME.txt"
EOF EOF
@ -216,7 +216,7 @@ edit_note_no_modifications() {
NOTE_FILE="$(ls "$(pwd)/notes/cur"/*)" NOTE_FILE="$(ls "$(pwd)/notes/cur"/*)"
cat > "$(pwd)/editor.sh" <<- EOF cat > "$(pwd)/editor.sh" <<- EOF
#!/bin/bash #!/usr/bin/env bash
EOF EOF
chmod a+x "$(pwd)/editor.sh" chmod a+x "$(pwd)/editor.sh"
export EDITOR="$(pwd)/editor.sh" export EDITOR="$(pwd)/editor.sh"
@ -233,7 +233,7 @@ resume_editing() {
NOTE_ID="$(cat "$(pwd)/notes/cur"/* | grep X-Note-Id | cut -d ' ' -f 2)" NOTE_ID="$(cat "$(pwd)/notes/cur"/* | grep X-Note-Id | cut -d ' ' -f 2)"
cat > "$(pwd)/editor.sh" <<- EOF cat > "$(pwd)/editor.sh" <<- EOF
#!/bin/bash #!/usr/bin/env bash
FILENAME="\$1" FILENAME="\$1"
echo "myline2" >> "\$FILENAME" echo "myline2" >> "\$FILENAME"
exit 1 exit 1
@ -247,7 +247,7 @@ resume_editing() {
assert 'echo "$OUTPUT" | grep myline | wc -l | tr -d " "' "1" assert 'echo "$OUTPUT" | grep myline | wc -l | tr -d " "' "1"
cat > "$(pwd)/editor.sh" <<- EOF cat > "$(pwd)/editor.sh" <<- EOF
#!/bin/bash #!/usr/bin/env bash
FILENAME="\$1" FILENAME="\$1"
echo "myline3" >> "\$FILENAME" echo "myline3" >> "\$FILENAME"
EOF EOF