(t *testing.T)
| 62 | } |
| 63 | |
| 64 | func TestModuleWorkersDifferentNamesSucceed(t *testing.T) { |
| 65 | // Create a test configuration with a worker name |
| 66 | configWithWorkerName1 := ` |
| 67 | { |
| 68 | php_server { |
| 69 | worker { |
| 70 | name test-worker-1 |
| 71 | file ../testdata/worker-with-env.php |
| 72 | num 1 |
| 73 | } |
| 74 | } |
| 75 | }` |
| 76 | |
| 77 | // Parse the first configuration |
| 78 | d1 := caddyfile.NewTestDispenser(configWithWorkerName1) |
| 79 | app := &FrankenPHPApp{} |
| 80 | module1 := &FrankenPHPModule{} |
| 81 | |
| 82 | // Unmarshal the first configuration |
| 83 | err := module1.UnmarshalCaddyfile(d1) |
| 84 | require.NoError(t, err, "First module should be configured without errors") |
| 85 | |
| 86 | // Create a second test configuration with a different worker name |
| 87 | configWithWorkerName2 := ` |
| 88 | { |
| 89 | php_server { |
| 90 | worker { |
| 91 | name test-worker-2 |
| 92 | file ../testdata/worker-with-env.php |
| 93 | num 1 |
| 94 | } |
| 95 | } |
| 96 | }` |
| 97 | |
| 98 | // Parse the second configuration |
| 99 | d2 := caddyfile.NewTestDispenser(configWithWorkerName2) |
| 100 | module2 := &FrankenPHPModule{} |
| 101 | |
| 102 | // Unmarshal the second configuration |
| 103 | err = module2.UnmarshalCaddyfile(d2) |
| 104 | |
| 105 | // Verify that no error was returned |
| 106 | require.NoError(t, err, "Expected no error when two workers have different names") |
| 107 | |
| 108 | _, err = app.addModuleWorkers(module1.Workers...) |
| 109 | require.NoError(t, err, "Expected no error when adding the first module workers") |
| 110 | _, err = app.addModuleWorkers(module2.Workers...) |
| 111 | require.NoError(t, err, "Expected no error when adding the second module workers") |
| 112 | |
| 113 | // Verify that both workers were added |
| 114 | require.Len(t, app.Workers, 2, "Expected two workers in the app") |
| 115 | require.Equal(t, "m#test-worker-1", app.Workers[0].Name, "First worker should have the correct name") |
| 116 | require.Equal(t, "m#test-worker-2", app.Workers[1].Name, "Second worker should have the correct name") |
| 117 | } |
| 118 | |
| 119 | func TestModuleWorkerWithEnvironmentVariables(t *testing.T) { |
| 120 | // Create a test configuration with environment variables |
nothing calls this directly
no test coverage detected