From 4c9e9468aa54f2080bf680e64af4f6deec660912 Mon Sep 17 00:00:00 2001 From: Duncan McGreggor Date: Sun, 31 Dec 2023 20:45:13 -0600 Subject: [PATCH] Updated integration tests. --- tests/mdsplode.sh | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/tests/mdsplode.sh b/tests/mdsplode.sh index 6f0978b..399e691 100755 --- a/tests/mdsplode.sh +++ b/tests/mdsplode.sh @@ -34,3 +34,40 @@ mdsplode --input "$MD_FILE" \ --query '.children.nodes[] | select(.name == "toml") | .json' | \ jq -r . | jq .frontmatter echo + +header "Process markdown to file ($TMP_DIR/out.json)" +mkdir -p $TMP_DIR +mdsplode --input "$MD_FILE" --output "$TMP_DIR/out.json" +echo + +header "Read from $TMP_DIR/out.json" +cat "$TMP_DIR/out.json" +echo +echo + +header "Process again to same markdown file ($TMP_DIR/out.json)" +mdsplode --input "$MD_FILE" --output "$TMP_DIR/out.json" +echo + +header "Re-read from $TMP_DIR/out.json" +cat "$TMP_DIR/out.json" +echo +echo + +header "Skip processing, read from $TMP_DIR/out.json, and apply query" +mdsplode --skip-process --input "$TMP_DIR/out.json" \ +--query '.children.nodes[] | select((.depth == 3) and .name == "heading") | .children.nodes[].source' +echo + +header "Process multiple markdown files ($MD_DIR/)" +rm -rf $TMP_DIR/many-md-files +mkdir -p $TMP_DIR/many-md-files +mdsplode --input "$MD_DIR" --output "$TMP_DIR/many-md-files" +find $TMP_DIR/many-md-files -type f -ls +echo + +header "View title from each of the multiple files" +mdsplode --skip-process --input "$TMP_DIR/many-md-files" --log-level info \ +--query '.children.nodes[] | select(.name == "toml") | .json' | \ +tr ',' '\n'|egrep -e '"title|INFO' +echo