summaryrefslogtreecommitdiff
path: root/server_config_test.go
diff options
context:
space:
mode:
authorWolfy-J <[email protected]>2018-09-10 16:42:15 +0400
committerGitHub <[email protected]>2018-09-10 16:42:15 +0400
commita554a98dda0d793da09db17314ef3977a2f3a465 (patch)
tree64b506898d283c39babc48da5a29df203cb57b49 /server_config_test.go
parentea97c188a4a74c00b585cb50fa1ed4db7d190e09 (diff)
parent46a06a4d104802fb4271e06da487f74f23edd10c (diff)
Merge pull request #33 from spiral/feature/env-setterv1.2.0
Feature/env setter
Diffstat (limited to 'server_config_test.go')
-rw-r--r--server_config_test.go44
1 files changed, 44 insertions, 0 deletions
diff --git a/server_config_test.go b/server_config_test.go
index 1831ae95..e116323d 100644
--- a/server_config_test.go
+++ b/server_config_test.go
@@ -4,6 +4,7 @@ import (
"github.com/stretchr/testify/assert"
"runtime"
"testing"
+ "time"
)
func Test_ServerConfig_PipeFactory(t *testing.T) {
@@ -90,3 +91,46 @@ func Test_ServerConfig_Cmd(t *testing.T) {
cmd := cfg.makeCommand()
assert.NotNil(t, cmd)
}
+
+func Test_ServerConfig_SetEnv(t *testing.T) {
+ cfg := &ServerConfig{
+ Command: "php php-src/tests/client.php pipes",
+ }
+
+ cfg.SetEnv("key", "value")
+
+ cmd := cfg.makeCommand()
+ assert.NotNil(t, cmd)
+
+ c := cmd()
+
+ assert.Contains(t, c.Env, "KEY=value")
+}
+
+func Test_ServerConfigDefaults(t *testing.T) {
+ cfg := &ServerConfig{
+ Command: "php php-src/tests/client.php pipes",
+ }
+
+ cfg.SetDefaults()
+
+ assert.Equal(t, "pipes", cfg.Relay)
+ assert.Equal(t, time.Minute, cfg.Pool.AllocateTimeout)
+ assert.Equal(t, time.Minute, cfg.Pool.DestroyTimeout)
+}
+
+func Test_Config_Upscale(t *testing.T) {
+ cfg := &ServerConfig{
+ Command: "php php-src/tests/client.php pipes",
+ RelayTimeout: 1,
+ Pool: &Config{
+ AllocateTimeout: 1,
+ DestroyTimeout: 1,
+ },
+ }
+
+ cfg.UpscaleDurations()
+ assert.Equal(t, time.Second, cfg.RelayTimeout)
+ assert.Equal(t, time.Second, cfg.Pool.AllocateTimeout)
+ assert.Equal(t, time.Second, cfg.Pool.DestroyTimeout)
+}