summaryrefslogtreecommitdiff
path: root/server_config_test.go
diff options
context:
space:
mode:
authorWolfy-J <[email protected]>2018-09-10 15:11:55 +0300
committerWolfy-J <[email protected]>2018-09-10 15:11:55 +0300
commit5dcbd1fd465956ee377c67f3b5d5a17701af235a (patch)
tree92a649424717478487e0d9f5a51da8b6584456c0 /server_config_test.go
parent6f70e31df4a88b85e576789ebe4fee6b5fc12d86 (diff)
more tests
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)
+}