github.com/gophercloud/gophercloud@v1.11.0/openstack/cdn/v1/base/testing/requests_test.go (about)

     1  package testing
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/gophercloud/gophercloud/openstack/cdn/v1/base"
     7  	th "github.com/gophercloud/gophercloud/testhelper"
     8  	fake "github.com/gophercloud/gophercloud/testhelper/client"
     9  )
    10  
    11  func TestGetHomeDocument(t *testing.T) {
    12  	th.SetupHTTP()
    13  	defer th.TeardownHTTP()
    14  	HandleGetSuccessfully(t)
    15  
    16  	actual, err := base.Get(fake.ServiceClient()).Extract()
    17  	th.CheckNoErr(t, err)
    18  
    19  	expected := base.HomeDocument{
    20  		"resources": map[string]interface{}{
    21  			"rel/cdn": map[string]interface{}{
    22  				"href-template": "services{?marker,limit}",
    23  				"href-vars": map[string]interface{}{
    24  					"marker": "param/marker",
    25  					"limit":  "param/limit",
    26  				},
    27  				"hints": map[string]interface{}{
    28  					"allow": []interface{}{"GET"},
    29  					"formats": map[string]interface{}{
    30  						"application/json": map[string]interface{}{},
    31  					},
    32  				},
    33  			},
    34  		},
    35  	}
    36  	th.CheckDeepEquals(t, expected, *actual)
    37  }
    38  
    39  func TestPing(t *testing.T) {
    40  	th.SetupHTTP()
    41  	defer th.TeardownHTTP()
    42  	HandlePingSuccessfully(t)
    43  
    44  	err := base.Ping(fake.ServiceClient()).ExtractErr()
    45  	th.CheckNoErr(t, err)
    46  }