mirror of
https://github.com/jimeh/tmuxifier.git
synced 2026-02-19 01:46:40 +00:00
Clean up test a bit
This commit is contained in:
@@ -9,9 +9,9 @@ source "${root}/lib/layout-helpers.sh"
|
||||
# When called without arguments, creates new window.
|
||||
create-test-session
|
||||
stub __go_to_window_or_session_path
|
||||
assert "test-socket-tmux list-windows | wc -l | awk '{print \$1}'" "1"
|
||||
assert "test-socket-window-count" "1"
|
||||
new_window
|
||||
assert "test-socket-tmux list-windows | wc -l | awk '{print \$1}'" "2"
|
||||
assert "test-socket-window-count" "2"
|
||||
assert "stub_called_times __go_to_window_or_session_path" "1"
|
||||
restore __go_to_window_or_session_path
|
||||
kill-test-session
|
||||
@@ -19,11 +19,10 @@ kill-test-session
|
||||
# When called with name argument, creates new window with specified name.
|
||||
create-test-session
|
||||
stub __go_to_window_or_session_path
|
||||
assert "test-socket-tmux list-windows | wc -l | awk '{print \$1}'" "1"
|
||||
assert "test-socket-tmux list-windows | grep yippieezzz | wc -l | awk '{print \$1}'" "0"
|
||||
assert "test-socket-window-count yippieezzz" "0"
|
||||
new_window "yippieezzz"
|
||||
assert "test-socket-tmux list-windows | wc -l | awk '{print \$1}'" "2"
|
||||
assert "test-socket-tmux list-windows | grep yippieezzz | wc -l | awk '{print \$1}'" "1"
|
||||
assert "test-socket-window-count" "2"
|
||||
assert "test-socket-window-count yippieezzz" "1"
|
||||
restore __go_to_window_or_session_path
|
||||
kill-test-session
|
||||
|
||||
@@ -32,16 +31,17 @@ kill-test-session
|
||||
rm "/tmp/tmuxifier-new_window-test" &> /dev/null
|
||||
create-test-session
|
||||
stub __go_to_window_or_session_path
|
||||
assert "test-socket-tmux list-windows | wc -l | awk '{print \$1}'" "1"
|
||||
assert "test-socket-tmux list-windows | grep foobardoo | wc -l | awk '{print \$1}'" "0"
|
||||
new_window "foobardoo" "touch /tmp/tmuxifier-new_window-test; bash"
|
||||
assert "test-socket-tmux list-windows | wc -l | awk '{print \$1}'" "2"
|
||||
assert "test-socket-tmux list-windows | grep foobardoo | wc -l | awk '{print \$1}'" "1"
|
||||
assert "test-socket-window-count" "2"
|
||||
assert "test-socket-window-count foobardoo" "1"
|
||||
assert_raises 'test -f "/tmp/tmuxifier-new_window-test"' 0
|
||||
restore __go_to_window_or_session_path
|
||||
kill-test-session
|
||||
rm "/tmp/tmuxifier-new_window-test" &> /dev/null
|
||||
|
||||
|
||||
# Tear down.
|
||||
kill-test-server
|
||||
|
||||
# End of tests.
|
||||
assert_end "new_window()"
|
||||
|
||||
@@ -48,6 +48,10 @@ source "${testroot}/assert.sh"
|
||||
source "${testroot}/stub.sh"
|
||||
|
||||
|
||||
#
|
||||
# Test Helpers
|
||||
#
|
||||
|
||||
test-socket-tmux() {
|
||||
export TMUXIFIER_TMUX_OPTS="-L tmuxifier-tests"
|
||||
"$TMUX_BIN" $TMUXIFIER_TMUX_OPTS $@
|
||||
@@ -72,3 +76,12 @@ kill-test-server() {
|
||||
unset TMUXIFIER_TMUX_OPTS
|
||||
unset session
|
||||
}
|
||||
|
||||
test-socket-window-count() {
|
||||
local list="$(test-socket-tmux list-windows)"
|
||||
if [ -n "$1" ]; then
|
||||
echo "$list" | grep $1 | wc -l | awk '{print $1}'
|
||||
else
|
||||
echo "$list" | wc -l | awk '{print $1}'
|
||||
fi
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user