diff options
-rw-r--r-- | server_config.go | 2 | ||||
-rw-r--r-- | server_config_test.go | 20 |
2 files changed, 21 insertions, 1 deletions
diff --git a/server_config.go b/server_config.go index db13382b..454b7992 100644 --- a/server_config.go +++ b/server_config.go @@ -76,7 +76,7 @@ func (cfg *ServerConfig) makeCommand() func() *exec.Cmd { return func() *exec.Cmd { cmd := exec.Command(cmd[0], cmd[1:]...) cmd.Env = append(os.Environ(), fmt.Sprintf("RR_RELAY=%s", cfg.Relay)) - cmd.Env = append(os.Environ(), cfg.env...) + cmd.Env = append(cmd.Env, cfg.env...) return cmd } } diff --git a/server_config_test.go b/server_config_test.go index ec29412e..429dd314 100644 --- a/server_config_test.go +++ b/server_config_test.go @@ -95,6 +95,7 @@ func Test_ServerConfig_Cmd(t *testing.T) { func Test_ServerConfig_SetEnv(t *testing.T) { cfg := &ServerConfig{ Command: "php tests/client.php pipes", + Relay: "pipes", } cfg.SetEnv("key", "value") @@ -105,6 +106,25 @@ func Test_ServerConfig_SetEnv(t *testing.T) { c := cmd() assert.Contains(t, c.Env, "KEY=value") + assert.Contains(t, c.Env, "RR_RELAY=pipes") +} + + +func Test_ServerConfig_SetEnv_Relay(t *testing.T) { + cfg := &ServerConfig{ + Command: "php tests/client.php pipes", + Relay: "unix://rr.sock", + } + + cfg.SetEnv("key", "value") + + cmd := cfg.makeCommand() + assert.NotNil(t, cmd) + + c := cmd() + + assert.Contains(t, c.Env, "KEY=value") + assert.Contains(t, c.Env, "RR_RELAY=unix://rr.sock") } func Test_ServerConfigDefaults(t *testing.T) { |