github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/acceptance/openstack/fgs/v2/reserved_test.go (about)

     1  package v2
     2  
     3  import (
     4  	"strings"
     5  	"testing"
     6  
     7  	golangsdk "github.com/opentelekomcloud/gophertelekomcloud"
     8  	"github.com/opentelekomcloud/gophertelekomcloud/acceptance/clients"
     9  	"github.com/opentelekomcloud/gophertelekomcloud/acceptance/tools"
    10  	"github.com/opentelekomcloud/gophertelekomcloud/openstack/common/pointerto"
    11  	"github.com/opentelekomcloud/gophertelekomcloud/openstack/fgs/v2/function"
    12  	"github.com/opentelekomcloud/gophertelekomcloud/openstack/fgs/v2/reserved"
    13  	th "github.com/opentelekomcloud/gophertelekomcloud/testhelper"
    14  )
    15  
    16  func TestFunctionGraphListReserved(t *testing.T) {
    17  	client, err := clients.NewFuncGraphClient()
    18  	th.AssertNoErr(t, err)
    19  
    20  	t.Logf("Attempting to LIST FUNCGRAPH RESERVED INSTANCE CONFIGURATION")
    21  	listReservedConfigs, err := reserved.ListReservedInstConfigs(client, reserved.ListConfigOpts{})
    22  	th.AssertNoErr(t, err)
    23  	tools.PrintResource(t, listReservedConfigs)
    24  
    25  	t.Logf("Attempting to LIST FUNCGRAPH RESERVED INSTANCES")
    26  	listReserved, err := reserved.ListReservedInst(client, reserved.ListOpts{})
    27  	th.AssertNoErr(t, err)
    28  	tools.PrintResource(t, listReserved)
    29  }
    30  
    31  func TestFunctionGraphReservedLifecycle(t *testing.T) {
    32  	client, err := clients.NewFuncGraphClient()
    33  	th.AssertNoErr(t, err)
    34  
    35  	createResp, _ := createFunctionGraph(t, client)
    36  
    37  	funcUrn := strings.TrimSuffix(createResp.FuncURN, ":latest")
    38  
    39  	defer func(client *golangsdk.ServiceClient, id string) {
    40  		err = function.Delete(client, id)
    41  		th.AssertNoErr(t, err)
    42  	}(client, funcUrn)
    43  
    44  	t.Logf("Attempting to UPDATE FUNCGRAPH RESERVED INSTANCES")
    45  	updateResp, err := reserved.Update(client, reserved.UpdateOpts{
    46  		FuncUrn: funcUrn,
    47  		Count:   pointerto.Int(1),
    48  	})
    49  	th.AssertNoErr(t, err)
    50  
    51  	tools.PrintResource(t, updateResp)
    52  }