github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/db/v1/flavors/testing/fixtures.go (about)

     1  package testing
     2  
     3  import (
     4  	"fmt"
     5  	"testing"
     6  
     7  	"github.com/huaweicloud/golangsdk/testhelper/fixture"
     8  )
     9  
    10  const flavor = `
    11  {
    12  	"id": %s,
    13  	"links": [
    14  		{
    15  			"href": "https://openstack.example.com/v1.0/1234/flavors/%s",
    16  			"rel": "self"
    17  		},
    18  		{
    19  			"href": "https://openstack.example.com/flavors/%s",
    20  			"rel": "bookmark"
    21  		}
    22  	],
    23  	"name": "%s",
    24  	"ram": %d,
    25  	"str_id": "%s"
    26  }
    27  `
    28  
    29  var (
    30  	flavorID = "{flavorID}"
    31  	_baseURL = "/flavors"
    32  	resURL   = "/flavors/" + flavorID
    33  )
    34  
    35  var (
    36  	flavor1 = fmt.Sprintf(flavor, "1", "1", "1", "m1.tiny", 512, "1")
    37  	flavor2 = fmt.Sprintf(flavor, "2", "2", "2", "m1.small", 1024, "2")
    38  	flavor3 = fmt.Sprintf(flavor, "3", "3", "3", "m1.medium", 2048, "3")
    39  	flavor4 = fmt.Sprintf(flavor, "4", "4", "4", "m1.large", 4096, "4")
    40  	flavor5 = fmt.Sprintf(flavor, "null", "d1", "d1", "ds512M", 512, "d1")
    41  
    42  	listFlavorsResp = fmt.Sprintf(`{"flavors":[%s, %s, %s, %s, %s]}`, flavor1, flavor2, flavor3, flavor4, flavor5)
    43  	getFlavorResp   = fmt.Sprintf(`{"flavor": %s}`, flavor1)
    44  )
    45  
    46  func HandleList(t *testing.T) {
    47  	fixture.SetupHandler(t, _baseURL, "GET", "", listFlavorsResp, 200)
    48  }
    49  
    50  func HandleGet(t *testing.T) {
    51  	fixture.SetupHandler(t, resURL, "GET", "", getFlavorResp, 200)
    52  }