Skip to content

Commit 9e79df0

Browse files
feat: add tests for local wsh file copy cmd (#1911)
This adds tests for the corner cases of the `wsh file copy` command. At the moment, these focus on local copies since they are more easily replicated. --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 2aa3e4b commit 9e79df0

55 files changed

Lines changed: 780 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

tests/copytests/cases/test000.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# copy a file to one with a different name
2+
# ensure that the original exists
3+
set -e
4+
cd "$HOME/testcp"
5+
touch foo.txt
6+
7+
wsh file copy foo.txt bar.txt
8+
9+
if [ ! -f foo.txt ]; then
10+
echo "foo.txt does not exist"
11+
exit 1
12+
fi

tests/copytests/cases/test001.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# copy a file to one with a different name
2+
# ensure that the destination file exists
3+
set -e
4+
cd "$HOME/testcp"
5+
touch foo.txt
6+
7+
wsh file copy foo.txt bar.txt
8+
9+
if [ ! -f bar.txt ]; then
10+
echo "bar.txt does not exist"
11+
exit 1
12+
fi

tests/copytests/cases/test002.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# copy a file with contents
2+
# ensure the contents are the same
3+
set -e
4+
cd "$HOME/testcp"
5+
touch foo.txt
6+
echo "The quick brown fox jumps over the lazy dog" > foo.txt
7+
8+
wsh file copy foo.txt bar.txt
9+
10+
11+
FOO_MD5=$(md5sum foo.txt | cut -d " " -f1)
12+
BAR_MD5=$(md5sum bar.txt | cut -d " " -f1)
13+
if [ $FOO_MD5 != $BAR_MD5 ]; then
14+
echo "files are not the same"
15+
echo "FOO_MD5 is $FOO_MD5"
16+
echo "BAR_MD5 is $BAR_MD5"
17+
exit 1
18+
fi

tests/copytests/cases/test003.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# copy a file where source starts with ./
2+
# ensure the source file exists
3+
set -e
4+
cd "$HOME/testcp"
5+
touch foo.txt
6+
7+
wsh file copy ./foo.txt bar.txt
8+
9+
if [ ! -f foo.txt ]; then
10+
echo "foo.txt does not exist"
11+
exit 1
12+
fi

tests/copytests/cases/test004.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# copy a file where source starts with ./
2+
# ensure the destination file exists
3+
set -e
4+
cd "$HOME/testcp"
5+
touch foo.txt
6+
7+
wsh file copy ./foo.txt bar.txt
8+
9+
if [ ! -f bar.txt ]; then
10+
echo "bar.txt does not exist"
11+
exit 1
12+
fi

tests/copytests/cases/test005.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# copy a file where destination starts with ./
2+
# ensure the source file exists
3+
4+
set -e
5+
cd "$HOME/testcp"
6+
touch foo.txt
7+
8+
wsh file copy foo.txt ./bar.txt
9+
10+
if [ ! -f foo.txt ]; then
11+
echo "foo.txt does not exist"
12+
exit 1
13+
fi

tests/copytests/cases/test006.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# copy a file where destination starts with ./
2+
# ensure the destination file exists
3+
4+
set -e
5+
cd "$HOME/testcp"
6+
touch foo.txt
7+
8+
wsh file copy foo.txt ./bar.txt
9+
10+
if [ ! -f bar.txt ]; then
11+
echo "bar.txt does not exist"
12+
exit 1
13+
fi

tests/copytests/cases/test007.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# copy a file where source and destination start with ./
2+
# ensure the source file exists
3+
4+
set -e
5+
cd "$HOME/testcp"
6+
touch foo.txt
7+
8+
wsh file copy ./foo.txt ./bar.txt
9+
10+
if [ ! -f foo.txt ]; then
11+
echo "foo.txt does not exist"
12+
exit 1
13+
fi

tests/copytests/cases/test008.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# copy a file where source and destination start with ./
2+
# ensure the destination file exists
3+
4+
set -e
5+
cd "$HOME/testcp"
6+
touch foo.txt
7+
8+
wsh file copy ./foo.txt ./bar.txt
9+
10+
if [ ! -f bar.txt ]; then
11+
echo "bar.txt does not exist"
12+
exit 1
13+
fi

tests/copytests/cases/test009.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# copy a file to itself with the same literal name
2+
# ensure the operation fails and the file still exists
3+
4+
set -e
5+
cd "$HOME/testcp"
6+
touch foo.txt
7+
8+
wsh file copy foo.txt foo.txt >/dev/null 2>&1 && echo "copy should have failed" && exit 1
9+
10+
if [ ! -f foo.txt ]; then
11+
echo "foo.txt does not exist"
12+
exit 1
13+
fi

0 commit comments

Comments
 (0)