File tree Expand file tree Collapse file tree 3 files changed +29
-8
lines changed Expand file tree Collapse file tree 3 files changed +29
-8
lines changed Original file line number Diff line number Diff line change @@ -12,8 +12,14 @@ test_env=$(get_env "TEST_ENV" false)
12
12
13
13
echo " $cron_time backup >> /var/log/backup.log" > /etc/crontabs/root
14
14
15
- if [ " $test_env " = false ]; then
16
- echo " Launching cron service..."
17
- tail -F /var/log/backup.log &
18
- exec crond -f -L /var/log/cron.log
15
+ echo " Launching cron service..."
16
+
17
+ if [ ! -f " /var/log/backup.log" ]; then
18
+ touch /var/log/backup.log
19
+ fi
20
+
21
+ if [ " $test_env " = true ]; then
22
+ timeout 1 run-cron-service
23
+ else
24
+ run-cron-service
19
25
fi
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ set -euo pipefail
4
+
5
+ tail -F /var/log/backup.log &
6
+ exec crond -f -L /var/log/cron.log
Original file line number Diff line number Diff line change
1
+ @test " run-cron command runs without error" {
2
+ export TEST_ENV=true
3
+
4
+ run run-cron
5
+ [ " $status " -eq 124 ]
6
+ [ " ${lines[0]} " = " Launching cron service..." ]
7
+ [ " ${# lines[@]} " -eq 1 ]
8
+ }
9
+
1
10
@test " run-cron command creates default cron entry" {
2
11
export TEST_ENV=true
3
12
4
13
run run-cron
5
- [ " $status " -eq 0 ]
14
+ [ " $status " -eq 124 ]
6
15
[ " $( cat /etc/crontabs/root) " = " 0 0 * * * backup >> /var/log/backup.log" ]
7
16
}
8
17
11
20
export CRON_MINUTE=12
12
21
13
22
run run-cron
14
- [ " $status " -eq 0 ]
23
+ [ " $status " -eq 124 ]
15
24
[ " $( cat /etc/crontabs/root) " = " 12 0 * * * backup >> /var/log/backup.log" ]
16
25
}
17
26
20
29
export CRON_HOUR=5
21
30
22
31
run run-cron
23
- [ " $status " -eq 0 ]
32
+ [ " $status " -eq 124 ]
24
33
[ " $( cat /etc/crontabs/root) " = " 0 5 * * * backup >> /var/log/backup.log" ]
25
34
}
26
35
29
38
export CRON_TIME=" */10 9 * * sun"
30
39
31
40
run run-cron
32
- [ " $status " -eq 0 ]
41
+ [ " $status " -eq 124 ]
33
42
[ " $( cat /etc/crontabs/root) " = " */10 9 * * sun backup >> /var/log/backup.log" ]
34
43
}
You can’t perform that action at this time.
0 commit comments