-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test case for sort order by file-size after
This tests the fix from PR #88 and by having it in the test suite it will make sure that sorting by size dos not get broken again.
- Loading branch information
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#! /bin/bash | ||
cat <<--- | ||
This test validates that the sorting by file size works. | ||
-- | ||
use pup | ||
nginx_start | ||
|
||
# Ascending sort. | ||
previous='' | ||
while read -r size ; do | ||
if [[ ${size} = - ]] ; then | ||
continue | ||
fi | ||
if [[ -z ${previous} ]] ; then | ||
previous=${size} | ||
continue | ||
fi | ||
[[ ${previous} -le ${size} ]] || fail \ | ||
'Size %d should be smaller than %d\n' "${previous}" "${size}" | ||
done < <( fetch '/?C=S&O=A' \ | ||
| pup -p body table tbody 'td:nth-child(2)' text{} ) | ||
|
||
# Descending sort. | ||
previous='' | ||
while read -r size ; do | ||
if [[ ${size} = - ]] ; then | ||
continue | ||
fi | ||
if [[ -z ${previous} ]] ; then | ||
previous=${size} | ||
continue | ||
fi | ||
[[ ${previous} -ge ${size} ]] || fail \ | ||
'Size %d should be greater than %d\n' "${previous}" "${size}" | ||
done < <( fetch '/?C=S&O=D' \ | ||
| pup -p body table tbody 'td:nth-child(2)' text{} ) |