github.com/vnpaycloud-console/gophercloud/v2@v2.0.5/internal/acceptance/openstack/workflow/v2/executions_test.go (about)

     1  //go:build acceptance || workflow || executions
     2  
     3  package v2
     4  
     5  import (
     6  	"testing"
     7  
     8  	"github.com/vnpaycloud-console/gophercloud/v2/internal/acceptance/clients"
     9  	"github.com/vnpaycloud-console/gophercloud/v2/internal/acceptance/tools"
    10  	"github.com/vnpaycloud-console/gophercloud/v2/openstack/workflow/v2/executions"
    11  	th "github.com/vnpaycloud-console/gophercloud/v2/testhelper"
    12  )
    13  
    14  func TestExecutionsCreate(t *testing.T) {
    15  	client, err := clients.NewWorkflowV2Client()
    16  	th.AssertNoErr(t, err)
    17  
    18  	workflow, err := CreateWorkflow(t, client)
    19  	th.AssertNoErr(t, err)
    20  	defer DeleteWorkflow(t, client, workflow)
    21  
    22  	execution, err := CreateExecution(t, client, workflow)
    23  	th.AssertNoErr(t, err)
    24  	defer DeleteExecution(t, client, execution)
    25  
    26  	tools.PrintResource(t, execution)
    27  }
    28  
    29  func TestExecutionsList(t *testing.T) {
    30  	client, err := clients.NewWorkflowV2Client()
    31  	th.AssertNoErr(t, err)
    32  
    33  	workflow, err := CreateWorkflow(t, client)
    34  	th.AssertNoErr(t, err)
    35  	defer DeleteWorkflow(t, client, workflow)
    36  
    37  	execution, err := CreateExecution(t, client, workflow)
    38  	th.AssertNoErr(t, err)
    39  	defer DeleteExecution(t, client, execution)
    40  
    41  	list, err := ListExecutions(t, client, &executions.ListOpts{
    42  		Description: &executions.ListFilter{
    43  			Value: execution.Description,
    44  		},
    45  		CreatedAt: &executions.ListDateFilter{
    46  			Filter: executions.FilterGTE,
    47  			Value:  execution.CreatedAt,
    48  		},
    49  		Input: execution.Input,
    50  	})
    51  
    52  	th.AssertNoErr(t, err)
    53  	th.AssertEquals(t, 1, len(list))
    54  
    55  	tools.PrintResource(t, list)
    56  }