diff options
Diffstat (limited to 'service/http/config_test.go')
-rw-r--r-- | service/http/config_test.go | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/service/http/config_test.go b/service/http/config_test.go new file mode 100644 index 00000000..18e8ab3e --- /dev/null +++ b/service/http/config_test.go @@ -0,0 +1,88 @@ +package http + +import ( + "testing" + "os" + "github.com/stretchr/testify/assert" + "github.com/spiral/roadrunner" + "time" +) + +func Test_Config_Valid(t *testing.T) { + cfg := &Config{ + Enable: true, + Address: ":8080", + MaxRequest: 1024, + Uploads: &UploadsConfig{ + Dir: os.TempDir(), + Forbid: []string{".go"}, + }, + Workers: &roadrunner.ServerConfig{ + Command: "php php-src/tests/client.php echo pipes", + Relay: "pipes", + Pool: &roadrunner.Config{ + NumWorkers: 1, + AllocateTimeout: time.Second, + DestroyTimeout: time.Second, + }, + }, + } + + assert.NoError(t, cfg.Valid()) +} + +func Test_Config_NoUploads(t *testing.T) { + cfg := &Config{ + Enable: true, + Address: ":8080", + MaxRequest: 1024, + Workers: &roadrunner.ServerConfig{ + Command: "php php-src/tests/client.php echo pipes", + Relay: "pipes", + Pool: &roadrunner.Config{ + NumWorkers: 1, + AllocateTimeout: time.Second, + DestroyTimeout: time.Second, + }, + }, + } + + assert.Error(t, cfg.Valid()) +} + +func Test_Config_NoWorkers(t *testing.T) { + cfg := &Config{ + Enable: true, + Address: ":8080", + MaxRequest: 1024, + Uploads: &UploadsConfig{ + Dir: os.TempDir(), + Forbid: []string{".go"}, + }, + } + + assert.Error(t, cfg.Valid()) +} + +func Test_Confi_InvalidAddress(t *testing.T) { + cfg := &Config{ + Enable: true, + Address: "", + MaxRequest: 1024, + Uploads: &UploadsConfig{ + Dir: os.TempDir(), + Forbid: []string{".go"}, + }, + Workers: &roadrunner.ServerConfig{ + Command: "php php-src/tests/client.php echo pipes", + Relay: "pipes", + Pool: &roadrunner.Config{ + NumWorkers: 1, + AllocateTimeout: time.Second, + DestroyTimeout: time.Second, + }, + }, + } + + assert.Error(t, cfg.Valid()) +} |