(t *testing.T)
| 187 | } |
| 188 | |
| 189 | func 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 | } |
nothing calls this directly
no test coverage detected