(t *testing.T)
| 243 | } |
| 244 | |
| 245 | func TestNamedModuleWorkers(t *testing.T) { |
| 246 | var wg sync.WaitGroup |
| 247 | testPortNum, _ := strconv.Atoi(testPort) |
| 248 | testPortTwo := strconv.Itoa(testPortNum + 1) |
| 249 | tester := caddytest.NewTester(t) |
| 250 | initServer(t, tester, ` |
| 251 | { |
| 252 | skip_install_trust |
| 253 | admin localhost:2999 |
| 254 | } |
| 255 | |
| 256 | http://localhost:`+testPort+` { |
| 257 | route { |
| 258 | php { |
| 259 | root ../testdata |
| 260 | worker { |
| 261 | file worker-with-env.php |
| 262 | num 2 |
| 263 | env APP_ENV one |
| 264 | name module1 |
| 265 | } |
| 266 | } |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | http://localhost:`+testPortTwo+` { |
| 271 | route { |
| 272 | php { |
| 273 | root ../testdata |
| 274 | worker { |
| 275 | file worker-with-env.php |
| 276 | num 1 |
| 277 | env APP_ENV two |
| 278 | name module2 |
| 279 | } |
| 280 | } |
| 281 | } |
| 282 | } |
| 283 | `, "caddyfile") |
| 284 | |
| 285 | for i := range 10 { |
| 286 | wg.Add(1) |
| 287 | |
| 288 | go func(i int) { |
| 289 | tester.AssertGetResponse("http://localhost:"+testPort+"/worker-with-env.php", http.StatusOK, "Worker has APP_ENV=one") |
| 290 | tester.AssertGetResponse("http://localhost:"+testPortTwo+"/worker-with-env.php", http.StatusOK, "Worker has APP_ENV=two") |
| 291 | wg.Done() |
| 292 | }(i) |
| 293 | } |
| 294 | wg.Wait() |
| 295 | } |
| 296 | |
| 297 | func TestEnv(t *testing.T) { |
| 298 | tester := caddytest.NewTester(t) |
nothing calls this directly
no test coverage detected