Skip to content

Commit 840fa07

Browse files
committed
Add tests/folder_organiser_test.sh
1 parent 92b6f82 commit 840fa07

File tree

2 files changed

+69
-3
lines changed

2 files changed

+69
-3
lines changed

tests/cruft_remover_test.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,19 @@ function tear_down() {
1616
rm -rf "$TEST_DIR"
1717
}
1818

19-
function test_files_to_be_delete() {
19+
function test_files_to_be_delete_more_than_1_day() {
2020
local result="$(echo -e "$TEST_DIR\n1" | ./cruft_remover.sh)"
2121

2222
assert_equals "$(ls $TEST_DIR)" "file_3.txt"
2323
}
2424

25-
function test_files_cannot_to_be_delete() {
25+
function test_files_cannot_to_be_delete_more_than_2_day() {
2626
local result="$(echo -e "$TEST_DIR\n2" | ./cruft_remover.sh)"
2727

2828
assert_equals "$result" "There is no files matched."
2929
}
3030

31-
function test_wrong_dir_to_scan() {
31+
function test_dir_not_listed() {
3232
local result="$(echo -e "$TEST_DIR_NOT_CREATED" | ./cruft_remover.sh)"
3333

3434
assert_equals "$result" "Folder you type is not exists."

tests/folder_organiser_test.sh

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/usr/bin/env bash
2+
3+
test_dir="tmp"
4+
dir=({1..10}.jpg {1..10}.png {1..10}.doc {1..10}.docx {1..10}.pdf {1..10}.csv {1..10}.sh {1..10}.tar.bz2 {1..10}.pptx {1..10}.mp3 {1..10}.mp4 {1..10}.unknown)
5+
6+
function set_up() {
7+
mkdir "$test_dir"
8+
9+
for file in "${dir[@]}"; do
10+
touch "$test_dir/$file"
11+
done
12+
}
13+
14+
function tear_down() {
15+
for file in "${dir[@]}"; do
16+
rm "$test_dir/$file"
17+
done
18+
19+
rmdir "$test_dir"
20+
}
21+
22+
function test_cant_organise_unknown_files() {
23+
local unknown_files=($(ls "$test_dir"/*.unknown))
24+
assert_equals "${#unknown_files[@]}" "10"
25+
}
26+
27+
function test_can_organise_images() {
28+
local images=($(ls "$test_dir"/*.{jpg,png}))
29+
assert_equals "${#images[@]}" "$((10*2))"
30+
}
31+
32+
function test_can_organise_documents() {
33+
local docs=($(ls "$test_dir"/*.{doc,docx,pdf}))
34+
assert_equals "${#docs[@]}" "$((10*3))"
35+
}
36+
37+
function test_can_organise_spreadsheets() {
38+
local csv_files=($(ls "$test_dir"/*.csv))
39+
assert_equals "${#csv_files[@]}" "10"
40+
}
41+
42+
function test_can_organise_scripts() {
43+
local scripts=($(ls "$test_dir"/*.sh))
44+
assert_equals "${#scripts[@]}" "10"
45+
}
46+
47+
function test_can_organise_archives() {
48+
local archives=($(ls "$test_dir"/*.tar.bz2))
49+
assert_equals "${#archives[@]}" "10"
50+
}
51+
52+
function test_can_organise_presentations() {
53+
local presentations=($(ls "$test_dir"/*.pptx))
54+
assert_equals "${#presentations[@]}" "10"
55+
}
56+
57+
function test_can_organise_audio_files() {
58+
local audio_files=($(ls "$test_dir"/*.mp3))
59+
assert_equals "${#audio_files[@]}" "10"
60+
}
61+
62+
function test_can_organise_video_files() {
63+
local video_files=($(ls "$test_dir"/*.mp4))
64+
assert_equals "${#video_files[@]}" "10"
65+
}
66+

0 commit comments

Comments
 (0)