forked from beeryardtech/tmux-net-speed
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Format improvements, Doc update, unit tests!
- Added unit tests and suites - Updated the README - Whitespace fixes
- Loading branch information
Travis Goldie
committed
Jan 14, 2017
1 parent
8019483
commit c755d09
Showing
8 changed files
with
302 additions
and
68 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
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,6 @@ | ||
#!/bin/bash - | ||
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
|
||
for testSuite in $CURRENT_DIR/tests/suites/* ; do | ||
$testSuite | ||
done |
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
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
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
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
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,132 @@ | ||
#!/bin/bash - | ||
|
||
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
SCRIPTS="$CURRENT_DIR/../../scripts" | ||
source "$CURRENT_DIR/../test_utils.sh" | ||
|
||
## | ||
# Description: | ||
# General setup before each test | ||
## | ||
setup() | ||
{ | ||
source "$SCRIPTS/helpers.sh" | ||
} | ||
|
||
## | ||
# get_tmux_option | ||
## | ||
setup_get_tmux_option() | ||
{ | ||
setup | ||
|
||
## Set generic property | ||
tmux set @get_tmux_option_name "get_tmux_option_val" | ||
} | ||
|
||
cleanup_get_tmux_option() | ||
{ | ||
# Unset value | ||
tmux set -u @get_tmux_option_name | ||
} | ||
|
||
test_get_tmux_option() | ||
{ | ||
## | ||
# Should return set value | ||
## | ||
setup_get_tmux_option | ||
|
||
result=$( get_tmux_option "@get_tmux_option_name") | ||
assertEqual "$result" "get_tmux_option_val" "should get tmux prop when given no default" -v | ||
|
||
cleanup_get_tmux_option | ||
|
||
## | ||
# Should show set value | ||
## | ||
setup_get_tmux_option | ||
|
||
result=$( get_tmux_option "@get_tmux_option_name_unset") | ||
assertEqual "$result" "" "should get empty string when tmux prop unset" | ||
|
||
cleanup_get_tmux_option | ||
|
||
## | ||
# Should show set value | ||
## | ||
setup_get_tmux_option | ||
|
||
result=$( get_tmux_option @get_tmux_option_name_unset my_default) | ||
assertEqual "$result" "my_default" "should get default if provided for unset prop" | ||
|
||
cleanup_get_tmux_option | ||
} | ||
|
||
## | ||
# get_velocity | ||
## | ||
setup_get_velocity() | ||
{ | ||
setup | ||
} | ||
|
||
cleanup_get_velocity() { :; } | ||
|
||
test_get_velocity() | ||
{ | ||
setup_get_velocity | ||
let input=200 | ||
result=$(get_velocity $input 0) | ||
assertEqual "$result" "200 B/s" "should show B/s" | ||
cleanup_get_velocity | ||
|
||
setup_get_velocity | ||
let input=2*1024 | ||
result=$(get_velocity $input 0) | ||
assertEqual "$result" "2 KB/s" "should show KB/s" | ||
cleanup_get_velocity | ||
|
||
setup_get_velocity | ||
let input=3*1048576 | ||
result=$(get_velocity $input 0) | ||
assertEqual "$result" "3 MB/s" "should show MB/s" | ||
cleanup_get_velocity | ||
|
||
|
||
setup_get_velocity | ||
let subtract_from=100*1048576 | ||
let subtract_with=50*1048576 | ||
result=$(get_velocity $subtract_from subtract_with) | ||
assertEqual "$result" "50 MB/s" "should show MB/s if subraction done" | ||
cleanup_get_velocity | ||
} | ||
|
||
## | ||
# get_interfaces | ||
## | ||
setup_get_interfaces() | ||
{ | ||
setup | ||
} | ||
|
||
cleanup_get_interfaces() { :; } | ||
|
||
test_get_interfaces() | ||
{ | ||
setup_get_interfaces | ||
result=$(get_interfaces) | ||
assertEqual "$result" "eth0 lo wlan0" "should output space-delimited list of interfaces" -v | ||
cleanup_get_interfaces | ||
} | ||
|
||
suites() | ||
{ | ||
#test_get_tmux_option | ||
#test_get_velocity | ||
test_get_interfaces | ||
} | ||
|
||
# Run tests | ||
suites | ||
|
Oops, something went wrong.