(t *testing.T)
| 151 | } |
| 152 | |
| 153 | func TestModuleWorkerWithWatchConfiguration(t *testing.T) { |
| 154 | // Create a test configuration with watch directories |
| 155 | configWithWatch := ` |
| 156 | { |
| 157 | php { |
| 158 | worker { |
| 159 | file ../testdata/worker-with-env.php |
| 160 | num 1 |
| 161 | watch |
| 162 | watch ./src/**/*.php |
| 163 | watch ./config/**/*.yaml |
| 164 | } |
| 165 | } |
| 166 | }` |
| 167 | |
| 168 | // Parse the configuration |
| 169 | d := caddyfile.NewTestDispenser(configWithWatch) |
| 170 | module := &FrankenPHPModule{} |
| 171 | |
| 172 | // Unmarshal the configuration |
| 173 | err := module.UnmarshalCaddyfile(d) |
| 174 | |
| 175 | // Verify that no error was returned |
| 176 | require.NoError(t, err, "Expected no error when configuring a worker with watch directories") |
| 177 | |
| 178 | // Verify that the worker was added to the module |
| 179 | require.Len(t, module.Workers, 1, "Expected one worker to be added to the module") |
| 180 | require.Equal(t, "../testdata/worker-with-env.php", module.Workers[0].FileName, "Worker should have the correct filename") |
| 181 | |
| 182 | // Verify that the watch directories were set correctly |
| 183 | require.Len(t, module.Workers[0].Watch, 3, "Expected three watch patterns") |
| 184 | require.Equal(t, defaultWatchPattern, module.Workers[0].Watch[0], "First watch pattern should be the default") |
| 185 | require.Equal(t, "./src/**/*.php", module.Workers[0].Watch[1], "Second watch pattern should match the configuration") |
| 186 | require.Equal(t, "./config/**/*.yaml", module.Workers[0].Watch[2], "Third watch pattern should match the configuration") |
| 187 | } |
| 188 | |
| 189 | func TestModuleWorkerWithCustomName(t *testing.T) { |
| 190 | // Create a test configuration with a custom worker name |
nothing calls this directly
no test coverage detected