Skip to content

Commit 72d641d

Browse files
committed
all
1 parent a668c3f commit 72d641d

File tree

3 files changed

+124
-4
lines changed

3 files changed

+124
-4
lines changed

.scaffold/tests/bats/ahoy.bats

Lines changed: 121 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,114 @@ load _helper
44

55
export BATS_FIXTURE_EXPORT_CODEBASE_ENABLED=1
66

7-
# bats file_tags=p1
7+
@test "ahoy build" {
8+
run ahoy build
9+
assert_success
10+
assert_output_contains "PROVISION COMPLETE"
11+
}
12+
13+
@test "ahoy assemble" {
14+
run ahoy assemble
15+
assert_success
16+
17+
assert_output_contains "ASSEMBLE COMPLETE"
18+
assert_dir_exists "${BUILD_DIR}/build/vendor"
19+
assert_file_exists "${BUILD_DIR}/build/composer.json"
20+
assert_file_exists "${BUILD_DIR}/build/composer.lock"
21+
assert_dir_exists "${BUILD_DIR}/node_modules"
22+
assert_output_contains "Would run build"
23+
}
24+
25+
@test "ahoy assemble - skip NPM build" {
26+
touch ".skip_npm_build"
27+
28+
run ahoy assemble
29+
assert_success
30+
31+
assert_output_contains "ASSEMBLE COMPLETE"
32+
assert_dir_exists "${BUILD_DIR}/build/vendor"
33+
assert_file_exists "${BUILD_DIR}/build/composer.json"
34+
assert_file_exists "${BUILD_DIR}/build/composer.lock"
35+
assert_dir_exists "${BUILD_DIR}/node_modules"
36+
assert_output_not_contains "Would run build"
37+
}
38+
39+
@test "ahoy start" {
40+
run ahoy start
41+
assert_failure
42+
assert_output_not_contains "ENVIRONMENT READY"
43+
44+
ahoy assemble
45+
run ahoy start
46+
assert_success
47+
48+
assert_output_contains "ENVIRONMENT READY"
49+
}
50+
51+
@test "ahoy stop" {
52+
run ahoy stop
53+
assert_success
54+
assert_output_contains "ENVIRONMENT STOPPED"
55+
56+
ahoy assemble
57+
ahoy start
58+
59+
run ahoy stop
60+
assert_success
61+
assert_output_contains "ENVIRONMENT STOPPED"
62+
}
63+
64+
@test "ahoy build - basic workflow" {
65+
run ahoy build
66+
assert_success
67+
assert_output_contains "PROVISION COMPLETE"
68+
69+
run ahoy drush status
70+
assert_success
71+
assert_output_contains "Database : Connected"
72+
assert_output_contains "Drupal bootstrap : Successful"
73+
74+
run ahoy login
75+
assert_success
76+
assert_output_contains "user/reset/1/"
77+
78+
ahoy lint
79+
assert_success
80+
81+
ahoy test
82+
assert_success
83+
assert_dir_exists "${BUILD_DIR}/build/web/sites/simpletest/browser_output"
84+
}
85+
86+
@test "ahoy lint, lint-fix" {
87+
ahoy assemble
88+
assert_success
89+
90+
ahoy lint
91+
assert_success
92+
93+
# shellcheck disable=SC2016
94+
echo '$a=123;echo $a;' >>your_extension.module
95+
run ahoy lint
96+
assert_failure
97+
98+
run ahoy lint-fix
99+
run ahoy lint
100+
assert_success
101+
}
102+
103+
@test "ahoy test unit failure" {
104+
run ahoy assemble
105+
assert_success
106+
107+
run ahoy test-unit
108+
assert_success
109+
110+
sed -i -e "s/assertEquals/assertNotEquals/g" "${BUILD_DIR}/tests/src/Unit/YourExtensionServiceUnitTest.php"
111+
run ahoy test-unit
112+
assert_failure
113+
}
114+
8115
@test "ahoy test functional failure" {
9116
run ahoy build
10117
assert_success
@@ -14,7 +121,20 @@ export BATS_FIXTURE_EXPORT_CODEBASE_ENABLED=1
14121
assert_dir_exists "${BUILD_DIR}/build/web/sites/simpletest/browser_output"
15122
rm -Rf "${BUILD_DIR}/build/web/sites/simpletest/browser_output" || true
16123

124+
rm -Rf "${BUILD_DIR}/build/web/sites/simpletest/browser_output" || true
17125
sed -i -e "s/responseContains/responseNotContains/g" "${BUILD_DIR}/tests/src/Functional/YourExtensionFunctionalTest.php"
18126
run ahoy test-functional
19127
assert_failure
20128
}
129+
130+
@test "ahoy test kernel failure" {
131+
run ahoy build
132+
assert_success
133+
134+
run ahoy test-kernel
135+
assert_success
136+
137+
sed -i -e "s/assertEquals/assertNotEquals/g" "${BUILD_DIR}/tests/src/Kernel/YourExtensionServiceKernelTest.php"
138+
run ahoy test-kernel
139+
assert_failure
140+
}

.scaffold/tests/bats/make.bats

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ load _helper
44

55
export BATS_FIXTURE_EXPORT_CODEBASE_ENABLED=1
66

7-
# bats file_tags=p2-skipped
7+
# bats file_tags=p2
88
@test "make default" {
99
run make
1010
assert_success
@@ -131,7 +131,6 @@ export BATS_FIXTURE_EXPORT_CODEBASE_ENABLED=1
131131
sed -i -e "s/responseContains/responseNotContains/g" "${BUILD_DIR}/tests/src/Functional/YourExtensionFunctionalTest.php"
132132
run make test-functional
133133
assert_failure
134-
assert_dir_not_exists "${BUILD_DIR}/build/web/sites/simpletest/browser_output"
135134
}
136135

137136
@test "make test kernel failure" {

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
SHELL=/bin/bash
22
WEBSERVER_HOST ?= localhost
33
WEBSERVER_PORT ?= 8000
4-
BROWSERTEST_OUTPUT_DIRECTORY ?= $(shell pwd)/.logs
4+
BROWSERTEST_OUTPUT_DIRECTORY ?= $(TMPDIR)
5+
BROWSERTEST_OUTPUT_DIRECTORY ?= /tmp
56

67
.PHONY: assemble, build, help, lint, lint-fix, login, provision, reset, start, status, stop, test, test-functional, test-kernel, test-unit
78

0 commit comments

Comments
 (0)