diff options
author | Wolfy-J <[email protected]> | 2018-06-06 12:59:38 +0300 |
---|---|---|
committer | Wolfy-J <[email protected]> | 2018-06-06 12:59:38 +0300 |
commit | b49a888579be9dfc33069d168083c54fb354e24c (patch) | |
tree | 877c0e4397135f83f4794bc72e4adcaf43cc3c24 /server_config_test.go | |
parent | aefb8c50d2c691cac113d9ccbbfbcbd30635ee6a (diff) |
more tests
Diffstat (limited to 'server_config_test.go')
-rw-r--r-- | server_config_test.go | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/server_config_test.go b/server_config_test.go new file mode 100644 index 00000000..667cfced --- /dev/null +++ b/server_config_test.go @@ -0,0 +1,60 @@ +package roadrunner + +import ( + "testing" + "github.com/stretchr/testify/assert" +) + +func Test_ServerConfig_PipeFactory(t *testing.T) { + cfg := &ServerConfig{Relay: "pipes"} + f, err := cfg.makeFactory() + + assert.NoError(t, err) + assert.IsType(t, &PipeFactory{}, f) + + cfg = &ServerConfig{Relay: "pipe"} + f, err = cfg.makeFactory() + defer f.Close() + + assert.NoError(t, err) + assert.IsType(t, &PipeFactory{}, f) +} + +func Test_ServerConfig_SocketFactory(t *testing.T) { + cfg := &ServerConfig{Relay: "tcp://:9000"} + f, err := cfg.makeFactory() + defer f.Close() + + assert.NoError(t, err) + assert.IsType(t, &SocketFactory{}, f) + assert.Equal(t, "tcp", f.(*SocketFactory).ls.Addr().Network(), ) + assert.Equal(t, "[::]:9000", f.(*SocketFactory).ls.Addr().String()) + + cfg = &ServerConfig{Relay: "tcp://localhost:9000"} + f, err = cfg.makeFactory() + defer f.Close() + + assert.NoError(t, err) + assert.IsType(t, &SocketFactory{}, f) + assert.Equal(t, "tcp", f.(*SocketFactory).ls.Addr().Network()) + assert.Equal(t, "127.0.0.1:9000", f.(*SocketFactory).ls.Addr().String()) +} + +func Test_ServerConfig_UnixSocketFactory(t *testing.T) { + cfg := &ServerConfig{Relay: "unix://unix.sock"} + f, err := cfg.makeFactory() + defer f.Close() + + assert.NoError(t, err) + assert.IsType(t, &SocketFactory{}, f) + assert.Equal(t, "unix", f.(*SocketFactory).ls.Addr().Network()) + assert.Equal(t, "unix.sock", f.(*SocketFactory).ls.Addr().String()) +} + +func Test_ServerConfig_ErrorFactory(t *testing.T) { + cfg := &ServerConfig{Relay: "uni:unix.sock"} + f, err := cfg.makeFactory() + assert.Nil(t, f) + assert.Error(t, err) + assert.Equal(t, "invalid relay DSN (pipes, tcp://:6001, unix://rr.sock)", err.Error()) +} |