MCPcopy Index your code
hub / github.com/php/frankenphp / TestModuleWorkerWithCustomName

Function TestModuleWorkerWithCustomName

caddy/config_test.go:189–222  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

187}
188
189func TestModuleWorkerWithCustomName(t *testing.T) {
190 // Create a test configuration with a custom worker name
191 configWithCustomName := `
192 {
193 php {
194 worker {
195 file ../testdata/worker-with-env.php
196 num 1
197 name custom-worker-name
198 }
199 }
200 }`
201
202 // Parse the configuration
203 d := caddyfile.NewTestDispenser(configWithCustomName)
204 module := &FrankenPHPModule{}
205 app := &FrankenPHPApp{}
206
207 // Unmarshal the configuration
208 err := module.UnmarshalCaddyfile(d)
209
210 // Verify that no error was returned
211 require.NoError(t, err, "Expected no error when configuring a worker with a custom name")
212
213 // Verify that the worker was added to the module
214 require.Len(t, module.Workers, 1, "Expected one worker to be added to the module")
215 require.Equal(t, "../testdata/worker-with-env.php", module.Workers[0].FileName, "Worker should have the correct filename")
216
217 // Verify that the worker was added to app.Workers with the m# prefix
218 module.Workers, err = app.addModuleWorkers(module.Workers...)
219 require.NoError(t, err, "Expected no error when adding the worker to the app")
220 require.Equal(t, "m#custom-worker-name", module.Workers[0].Name, "Worker should have the custom name, prefixed with m#")
221 require.Equal(t, "m#custom-worker-name", app.Workers[0].Name, "Worker should have the custom name, prefixed with m#")
222}

Callers

nothing calls this directly

Calls 2

UnmarshalCaddyfileMethod · 0.95
addModuleWorkersMethod · 0.95

Tested by

no test coverage detected