github.com/1and1/oneandone-cloudserver-sdk-go@v1.4.1/ping_test.go (about)

     1  package oneandone
     2  
     3  import (
     4  	"fmt"
     5  	"testing"
     6  )
     7  
     8  // ping tests
     9  
    10  func TestPing(t *testing.T) {
    11  	fmt.Println("PING...")
    12  	// API client with no token
    13  	client := New("", BaseUrl)
    14  	pong, err := client.Ping()
    15  	if err != nil {
    16  		t.Errorf("Ping failed. Error: " + err.Error())
    17  	}
    18  	if len(pong) == 0 {
    19  		t.Errorf("Empty PING response.")
    20  		return
    21  	}
    22  	if pong[0] != "PONG" {
    23  		t.Errorf("Invalid PING response.")
    24  	}
    25  }
    26  
    27  func TestPingAuth(t *testing.T) {
    28  	fmt.Println("PING with authorization check...")
    29  	pong, err := api.PingAuth()
    30  	if err != nil {
    31  		t.Errorf("Ping with authorization check failed. Error: " + err.Error())
    32  	}
    33  	if len(pong) == 0 {
    34  		t.Errorf("Empty PING authorization response.")
    35  		return
    36  	}
    37  	if pong[0] != "PONG" {
    38  		t.Errorf("Invalid PING authorization response.")
    39  	}
    40  }