コード例 #1
0
// creates new REST service
func testNewRest(t *testing.T) (service *rest.Service) {
	if len(testRestServerUrl) == 0 {
		return
	}

	service, err := rest.NewService(testRestServerUrl, testAccessKey)
	if err != nil {
		t.Errorf("Failed to create REST service (error: %s)", err)
	}
	return
}
コード例 #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
		}
	}
}
コード例 #3
0
ファイル: service.go プロジェクト: devicehive/devicehive-go
// NewRestService creates a new REST service.
// Base REST URL should be provided.
// Access key is optional, might be empty.
func NewRestService(baseUrl, accessKey string) (service Service, err error) {
	return rest.NewService(baseUrl, accessKey)
}