1
1
setup () {
2
2
set -eu -o pipefail
3
+
3
4
export DIR=" $( cd " $( dirname " $BATS_TEST_FILENAME " ) " > /dev/null 2>&1 && pwd) /.."
4
5
export TESTDIR=~ /tmp/test-laravel-queue
5
6
mkdir -p $TESTDIR
@@ -9,35 +10,39 @@ setup() {
9
10
cd " ${TESTDIR} "
10
11
}
11
12
13
+ teardown () {
14
+ set -eu -o pipefail
15
+ cd ${TESTDIR} || ( printf " unable to cd to ${TESTDIR} \n" && exit 1 )
16
+ ddev delete -Oy ${PROJNAME}
17
+ [ " ${TESTDIR} " != " " ] && rm -rf ${TESTDIR}
18
+ }
19
+
12
20
health_checks () {
13
- ddev exec " curl -s https://localhost:443 /"
21
+ ddev exec " curl -s https://web /"
14
22
}
15
23
16
24
queue_checks () {
25
+ set -eu -o pipefail
26
+
17
27
# Add a route that dispatches a job when hit
18
28
echo " Route::get('test-dispatch', function () {
29
+ logger('accessing test-dispatch ...');
30
+
19
31
dispatch(function () {
20
32
logger('hello from test-dispatch');
21
33
});
22
34
});" >> ./routes/web.php
23
35
24
36
# Visit the new route to trigger the dispatch
25
- ddev exec " curl -s https://localhost:443 /test-dispatch"
37
+ ddev exec " curl -s https://web /test-dispatch"
26
38
# We'll wait a few seconds to allow the queue worker to pick and process the job.
27
- sleep 5
39
+ sleep 10
28
40
29
41
if ! grep -q " hello from test-dispatch" ./storage/logs/laravel.log; then
30
42
exit 1;
31
43
fi
32
44
}
33
45
34
- teardown () {
35
- set -eu -o pipefail
36
- cd ${TESTDIR} || (printf " unable to cd to ${TESTDIR} \n" && exit 1)
37
- ddev delete -Oy ${PROJNAME} > /dev/null 2>&1
38
- [ " ${TESTDIR} " != " " ] && rm -rf ${TESTDIR}
39
- }
40
-
41
46
@test " install from directory" {
42
47
set -eu -o pipefail
43
48
cd ${TESTDIR}
@@ -49,18 +54,6 @@ teardown() {
49
54
health_checks
50
55
}
51
56
52
- # bats test_tags=release
53
- @test " install from release" {
54
- set -eu -o pipefail
55
- cd ${TESTDIR} || ( printf " unable to cd to ${TESTDIR} \n" && exit 1 )
56
- echo " # ddev add-on get tyler36/ddev-laravel-queue with project ${PROJNAME} in ${TESTDIR} ($( pwd) )" >&3
57
- ddev config --project-name=${PROJNAME}
58
- ddev start -y > /dev/null
59
- ddev add-on get tyler36/ddev-laravel-queue
60
- ddev restart > /dev/null
61
- health_checks
62
- }
63
-
64
57
@test " it processes jobs in Lavarel 11" {
65
58
set -eu -o pipefail
66
59
cd ${TESTDIR}
@@ -73,7 +66,6 @@ teardown() {
73
66
ddev add-on get ${DIR}
74
67
ddev restart
75
68
76
- health_checks
77
69
queue_checks
78
70
}
79
71
@@ -110,3 +102,15 @@ teardown() {
110
102
fi
111
103
done
112
104
}
105
+
106
+ # bats test_tags=release
107
+ @test " install from release" {
108
+ set -eu -o pipefail
109
+ cd ${TESTDIR} || ( printf " unable to cd to ${TESTDIR} \n" && exit 1 )
110
+ echo " # ddev add-on get tyler36/ddev-laravel-queue with project ${PROJNAME} in ${TESTDIR} ($( pwd) )" >&3
111
+ ddev config --project-name=${PROJNAME}
112
+ ddev start -y > /dev/null
113
+ ddev add-on get tyler36/ddev-laravel-queue
114
+ ddev restart > /dev/null
115
+ health_checks
116
+ }
0 commit comments