// creates new Websocket service
func testNewWs(t *testing.T) (service *ws.Service) {
	if len(testWsServerUrl) == 0 {
		return
	}

	service, err := ws.NewService(testWsServerUrl, testAccessKey)
	if err != nil {
		t.Errorf("Failed to create WS service (error: %s)", err)
	}
	return
}
// Test GetServerInfo method (invalid server address)
func TestGetServerInfoBadAddress(t *testing.T) {
	// REST
	if len(testRestServerUrl) != 0 {
		rs, err := rest.NewService(strings.Replace(testRestServerUrl, ".", "_", -1), "")
		if err != nil {
			t.Errorf("Failed to create service (error: %s)", err)
			return
		}

		_, err = rs.GetServerInfo(testWaitTimeout)
		if err == nil {
			t.Error("Expected 'unknown host' error")
		}
	}

	// Websocket
	if len(testWsServerUrl) != 0 {
		_, err := ws.NewService(strings.Replace(testWsServerUrl, ".", "_", -1), "")
		if err == nil {
			t.Errorf("Expected 'unknown host' error")
			return
		}
	}
}
Beispiel #3
0
// NewWebsocketService creates a new Websocket service.
// Base Websocket URL should be provided.
// Access key is optional, might be empty.
func NewWebsocketService(baseUrl, accessKey string) (service Service, err error) {
	return ws.NewService(baseUrl, accessKey)
}