github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/identity/v2/extensions/testing/fixtures.go (about)

     1  package testing
     2  
     3  import (
     4  	"fmt"
     5  	"net/http"
     6  	"testing"
     7  
     8  	th "github.com/huaweicloud/golangsdk/testhelper"
     9  	"github.com/huaweicloud/golangsdk/testhelper/client"
    10  )
    11  
    12  // ListOutput provides a single Extension result. It differs from the delegated implementation
    13  // by the introduction of an intermediate "values" member.
    14  const ListOutput = `
    15  {
    16  	"extensions": {
    17  		"values": [
    18  			{
    19  				"updated": "2013-01-20T00:00:00-00:00",
    20  				"name": "Neutron Service Type Management",
    21  				"links": [],
    22  				"namespace": "http://docs.openstack.org/ext/neutron/service-type/api/v1.0",
    23  				"alias": "service-type",
    24  				"description": "API for retrieving service providers for Neutron advanced services"
    25  			}
    26  		]
    27  	}
    28  }
    29  `
    30  
    31  // HandleListExtensionsSuccessfully creates an HTTP handler that returns ListOutput for a List
    32  // call.
    33  func HandleListExtensionsSuccessfully(t *testing.T) {
    34  	th.Mux.HandleFunc("/extensions", func(w http.ResponseWriter, r *http.Request) {
    35  		th.TestMethod(t, r, "GET")
    36  		th.TestHeader(t, r, "X-Auth-Token", client.TokenID)
    37  
    38  		w.Header().Add("Content-Type", "application/json")
    39  
    40  		fmt.Fprintf(w, `
    41  {
    42    "extensions": {
    43      "values": [
    44        {
    45          "updated": "2013-01-20T00:00:00-00:00",
    46          "name": "Neutron Service Type Management",
    47          "links": [],
    48          "namespace": "http://docs.openstack.org/ext/neutron/service-type/api/v1.0",
    49          "alias": "service-type",
    50          "description": "API for retrieving service providers for Neutron advanced services"
    51        }
    52      ]
    53    }
    54  }
    55      `)
    56  	})
    57  
    58  }