Skip to content

Commit

Permalink
REFACTOR-78: Add e2e test case when filter is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
grafviktor committed Oct 7, 2024
1 parent 2ead0b5 commit fa06730
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 13 deletions.
1 change: 1 addition & 0 deletions e2e/1_create.tape
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Type "gg -f temp"
Enter
Sleep 100ms
Type "n"
Sleep 100ms
Type "network host"
Down
Ctrl+u
Expand Down
1 change: 1 addition & 0 deletions e2e/2_copy.tape
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Type "gg -f temp"
Enter
Sleep 100ms
Type "n"
Sleep 100ms
Type "network host"
Down
Ctrl+u
Expand Down
1 change: 1 addition & 0 deletions e2e/3_delete.tape
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Type "gg -f temp"
Enter
Sleep 100ms
Type "n"
Sleep 100ms
Type "network host"
Down
Ctrl+u
Expand Down
32 changes: 32 additions & 0 deletions e2e/4_delete_filter_enabled.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Set Shell bash
Enter
Type "gg -f temp"
Enter
Sleep 100ms
Type "n"
Sleep 100ms
Type "network host"
Down
Ctrl+u
Type "127.0.0.1"
Down
Type "network host description"
Ctrl+S
Sleep 100ms
Type "c" # create "network host (1)"
Sleep 100ms
Type "c" # create "network host (2)"
Sleep 100ms
Type "c" # create "network host (3)"
Sleep 100ms
Type "c" # create "network host (4)"
Sleep 100ms
Type "c" # create "network host (5)"
Sleep 100ms
Type "/" # enter filter mode
Type "3" # enter "3", so only "network host (3)" is visible
Enter # Accept filter result
Type "d" # ask delete "network host (3)"
Type "y" # say "yes" to "network host (3)"
Sleep 100ms
Type "q"
20 changes: 20 additions & 0 deletions e2e/expected/4_delete_filter_enabled.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
- host:
title: network host
description: network host description
address: 127.0.0.1
- host:
title: network host (1)
description: network host description
address: 127.0.0.1
- host:
title: network host (2)
description: network host description
address: 127.0.0.1
- host:
title: network host (4)
description: network host description
address: 127.0.0.1
- host:
title: network host (5)
description: network host description
address: 127.0.0.1
34 changes: 21 additions & 13 deletions e2e/run.sh
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
#!/usr/bin/env bash

set -x
set -e

# cd to this file location
cd $(dirname "$(readlink -f "$0")")

export VHS_PUBLISH=false # disable "Host your GIF on vhs.charm.sh: vhs publish <file>.gif" message
TMP_HOME=temp
HOSTS_FILE="${TMP_HOME}"/hosts.yaml

function clean() {
function cleanup() {
rm -f out.gif "${TMP_HOME}"/*
}

mkdir -p "${TMP_HOME}"
clean
function cleanup_or_die() {
local exit_code="$1"
local file_name="$2"

vhs 1_create.tape > /dev/null
diff "${HOSTS_FILE}" expected/1_create.yaml || (echo Failed: 1_create.tape; exit 1)
clean
if [ "$exit_code" -ne 0 ]; then
echo "Failed: ${file_name}!"
exit 1;
fi

vhs 2_copy.tape > /dev/null
diff "${HOSTS_FILE}" expected/2_copy.yaml || (echo Failed: 2_copy.tape; exit 1)
clean
cleanup
}

mkdir -p "${TMP_HOME}"
cleanup

vhs 3_delete.tape > /dev/null
diff "${HOSTS_FILE}" expected/3_delete.yaml || (echo Failed: 3_delete.tape; exit 1)
clean
for file in *.tape; do
vhs "$file" > /dev/null
diff "${HOSTS_FILE}" "expected/${file%.*}.yaml" # file extension removed
cleanup_or_die $? "$file"
done

0 comments on commit fa06730

Please sign in to comment.