13
13
14
14
source " $HELPERS_PATH "
15
15
16
+ # Array to store test results
17
+ declare -a TEST_RESULTS
18
+
16
19
# Function to handle test failures
17
20
fail_test () {
18
- echo -e " \033[31m\033[1m$1 : FAIL\033[0m"
19
- exit 1
21
+ TEST_RESULTS+=(" $1 : \033[31m\033[1mFAIL\033[0m" )
22
+ }
23
+
24
+ # Function to handle test successes
25
+ pass_test () {
26
+ TEST_RESULTS+=(" $1 : \033[32m\033[1mPASS\033[0m" )
20
27
}
21
28
22
29
# Test reset function
23
30
echo " Testing reset function..."
24
31
reset_output=$( reset)
25
- if [[ " $reset_output " == * " restore clean working directory " * ]]; then
26
- echo -e " \033[32m\033[1mreset function: PASS\033[0m "
32
+ if [[ " $reset_output " == * " Here we go again! " * ]]; then
33
+ pass_test " reset function"
27
34
else
28
35
fail_test " reset function"
29
36
fi
32
39
echo " Testing get_default_branch_name function..."
33
40
default_branch=$( get_default_branch_name)
34
41
if [[ " $default_branch " == " main" || " $default_branch " == " master" ]]; then
35
- echo -e " \033[32m\033[1mget_default_branch_name function: PASS\033[0m "
42
+ pass_test " get_default_branch_name function"
36
43
else
37
44
fail_test " get_default_branch_name function"
38
45
fi
41
48
echo " Testing init_exercise function..."
42
49
init_exercise
43
50
if [[ -d " $SCRIPT_DIR /../../../beginners_git" ]]; then
44
- echo -e " \033[32m\033[1minit_exercise function: PASS\033[0m "
51
+ pass_test " init_exercise function"
45
52
else
46
53
fail_test " init_exercise function"
47
54
fi
50
57
echo " Testing init_repo_empty_schedule function..."
51
58
init_repo_empty_schedule
52
59
if [[ -f " $SCRIPT_DIR /../../../beginners_git/conference_planning/conference_schedule.txt" ]]; then
53
- echo -e " \033[32m\033[1minit_repo_empty_schedule function: PASS\033[0m "
60
+ pass_test " init_repo_empty_schedule function"
54
61
else
55
62
fail_test " init_repo_empty_schedule function"
56
63
fi
59
66
echo " Testing init_simple_repo function..."
60
67
init_simple_repo
61
68
if [[ -d " $SCRIPT_DIR /../../../beginners_git/conference_planning/.git" ]]; then
62
- echo -e " \033[32m\033[1minit_simple_repo function: PASS\033[0m "
69
+ pass_test " init_simple_repo function"
63
70
else
64
71
fail_test " init_simple_repo function"
65
72
fi
68
75
echo " Testing init_simple_repo_remote function..."
69
76
init_simple_repo_remote
70
77
if [[ -d " $SCRIPT_DIR /../../../beginners_git/conference_planning_remote/.git" ]]; then
71
- echo -e " \033[32m\033[1minit_simple_repo_remote function: PASS\033[0m "
78
+ pass_test " init_simple_repo_remote function"
72
79
else
73
80
fail_test " init_simple_repo_remote function"
74
81
fi
77
84
echo " Testing init_repo function..."
78
85
init_repo
79
86
if [[ -d " $SCRIPT_DIR /../../../beginners_git/conference_planning/.git" ]]; then
80
- echo -e " \033[32m\033[1minit_repo function: PASS\033[0m "
87
+ pass_test " init_repo function"
81
88
else
82
89
fail_test " init_repo function"
83
90
fi
86
93
echo " Testing init_repo_remote function..."
87
94
init_repo_remote
88
95
if [[ -d " $SCRIPT_DIR /../../../beginners_git/conference_planning/.git" && -d " $SCRIPT_DIR /../../../beginners_git/conference_planning_remote/" ]]; then
89
- echo -e " \033[32m\033[1minit_repo_remote function: PASS\033[0m "
96
+ pass_test " init_repo_remote function"
90
97
else
91
98
fail_test " init_repo_remote function"
92
99
fi
95
102
echo " Testing commit_to_remote_by_third_party function..."
96
103
commit_to_remote_by_third_party
97
104
if [[ -d " $SCRIPT_DIR /../../../beginners_git/conference_planning/.git" && -d " $SCRIPT_DIR /../../../beginners_git/conference_planning_remote/" ]]; then
98
- echo -e " \033[32m\033[1mcommit_to_remote_by_third_party function: PASS\033[0m "
105
+ pass_test " commit_to_remote_by_third_party function"
99
106
else
100
107
fail_test " commit_to_remote_by_third_party function"
101
- fi
108
+ fi
109
+
110
+ # Print summary
111
+ echo -e " \n\033[1mTest Summary:\033[0m"
112
+ for result in " ${TEST_RESULTS[@]} " ; do
113
+ echo -e " $result "
114
+ done
0 commit comments