Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion gh-md-toc
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,11 @@ gh_toc_md2html() {
-H "Content-Type:text/plain" \
-H "$AUTHORIZATION" \
"$URL")
local curl_status=$?

rm -f "${gh_file_md}~~"

if [ "$?" != "0" ]; then
if [ "$curl_status" != "0" ]; then
echo "XXNetworkErrorXX"
fi
if [ "$(echo "${OUTPUT}" | awk '/API rate limit exceeded/')" != "" ]; then
Expand Down
9 changes: 9 additions & 0 deletions tests/tests.bats
Original file line number Diff line number Diff line change
Expand Up @@ -233,3 +233,12 @@ test_help() {
assert_equal "${lines[8]}" "* [Title four is a particularly long title because of wrapping](#title-four-is-a-particularly-long-title-because-of-wrapping)"
assert_equal "${lines[9]}" " * [This is a test for long titles](#this-is-a-test-for-long-titles)"
}

@test "Error for local file without network access" {
# route curl through a closed port to simulate a network failure
HTTPS_PROXY=http://127.0.0.1:9 run $BATS_TEST_DIRNAME/../gh-md-toc tests/test\ directory/test_plussign.md
assert_fail

assert_equal "${lines[2]}" "Parsing local markdown file requires access to github API"
assert_equal "${lines[3]}" "Please make sure curl is installed and check your network connectivity"
}
Loading