Exemplo n.º 1
0
// 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
}
Exemplo n.º 2
0
// 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
		}
	}
}
Exemplo n.º 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)
}