github.com/gophercloud/gophercloud@v1.11.0/openstack/blockstorage/apiversions/testing/fixtures_test.go (about)

     1  package testing
     2  
     3  import (
     4  	"fmt"
     5  	"net/http"
     6  	"testing"
     7  
     8  	th "github.com/gophercloud/gophercloud/testhelper"
     9  	"github.com/gophercloud/gophercloud/testhelper/client"
    10  )
    11  
    12  const APIListResponse = `
    13  {
    14      "versions": [
    15          {
    16              "id": "v1.0",
    17              "links": [
    18                  {
    19                      "href": "http://docs.openstack.org/",
    20                      "rel": "describedby",
    21                      "type": "text/html"
    22                  },
    23                  {
    24                      "href": "http://localhost:8776/v1/",
    25                      "rel": "self"
    26                  }
    27              ],
    28              "media-types": [
    29                  {
    30                      "base": "application/json",
    31                      "type": "application/vnd.openstack.volume+json;version=1"
    32                  }
    33              ],
    34              "min_version": "",
    35              "status": "DEPRECATED",
    36              "updated": "2016-05-02T20:25:19Z",
    37              "version": ""
    38          },
    39          {
    40              "id": "v2.0",
    41              "links": [
    42                  {
    43                      "href": "http://docs.openstack.org/",
    44                      "rel": "describedby",
    45                      "type": "text/html"
    46                  },
    47                  {
    48                      "href": "http://localhost:8776/v2/",
    49                      "rel": "self"
    50                  }
    51              ],
    52              "media-types": [
    53                  {
    54                      "base": "application/json",
    55                      "type": "application/vnd.openstack.volume+json;version=1"
    56                  }
    57              ],
    58              "min_version": "",
    59              "status": "SUPPORTED",
    60              "updated": "2014-06-28T12:20:21Z",
    61              "version": ""
    62          },
    63          {
    64              "id": "v3.0",
    65              "links": [
    66                  {
    67                      "href": "http://docs.openstack.org/",
    68                      "rel": "describedby",
    69                      "type": "text/html"
    70                  },
    71                  {
    72                      "href": "http://localhost:8776/v3/",
    73                      "rel": "self"
    74                  }
    75              ],
    76              "media-types": [
    77                  {
    78                      "base": "application/json",
    79                      "type": "application/vnd.openstack.volume+json;version=1"
    80                  }
    81              ],
    82              "min_version": "3.0",
    83              "status": "CURRENT",
    84              "updated": "2016-02-08T12:20:21Z",
    85              "version": "3.27"
    86          }
    87      ]
    88  }
    89  `
    90  
    91  const APIListOldResponse = `
    92  {
    93    "versions": [
    94      {
    95        "status": "CURRENT",
    96        "updated": "2012-01-04T11:33:21Z",
    97        "id": "v1.0",
    98        "links": [
    99          {
   100            "href": "http://23.253.228.211:8776/v1/",
   101            "rel": "self"
   102          }
   103        ]
   104        },
   105      {
   106        "status": "CURRENT",
   107        "updated": "2012-11-21T11:33:21Z",
   108        "id": "v2.0",
   109        "links": [
   110          {
   111            "href": "http://23.253.228.211:8776/v2/",
   112            "rel": "self"
   113          }
   114        ]
   115      }
   116    ]
   117  }`
   118  
   119  func MockListResponse(t *testing.T) {
   120  	th.Mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
   121  		th.TestMethod(t, r, "GET")
   122  		th.TestHeader(t, r, "X-Auth-Token", client.TokenID)
   123  
   124  		w.Header().Add("Content-Type", "application/json")
   125  		w.WriteHeader(http.StatusOK)
   126  
   127  		fmt.Fprintf(w, APIListResponse)
   128  	})
   129  }
   130  
   131  func MockListOldResponse(t *testing.T) {
   132  	th.Mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
   133  		th.TestMethod(t, r, "GET")
   134  		th.TestHeader(t, r, "X-Auth-Token", client.TokenID)
   135  
   136  		w.Header().Add("Content-Type", "application/json")
   137  		w.WriteHeader(http.StatusOK)
   138  
   139  		fmt.Fprintf(w, APIListOldResponse)
   140  	})
   141  }