github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/acceptance/openstack/fgs/v2/invocation_test.go (about) 1 package v2 2 3 import ( 4 "os" 5 "strings" 6 "testing" 7 8 golangsdk "github.com/opentelekomcloud/gophertelekomcloud" 9 "github.com/opentelekomcloud/gophertelekomcloud/acceptance/clients" 10 "github.com/opentelekomcloud/gophertelekomcloud/acceptance/tools" 11 "github.com/opentelekomcloud/gophertelekomcloud/openstack/fgs/v2/function" 12 "github.com/opentelekomcloud/gophertelekomcloud/openstack/fgs/v2/invoke" 13 th "github.com/opentelekomcloud/gophertelekomcloud/testhelper" 14 ) 15 16 func TestFunctionGraphSync(t *testing.T) { 17 if funcGraph := os.Getenv("FUNCGRAPH_TEST"); funcGraph == "" { 18 t.Skip("`FUNCGRAPH_TEST`needs to be defined to run this test") 19 } 20 client, err := clients.NewFuncGraphClient() 21 th.AssertNoErr(t, err) 22 23 createResp, _ := createFunctionGraph(t, client) 24 25 funcUrn := strings.TrimSuffix(createResp.FuncURN, ":latest") 26 27 defer func(client *golangsdk.ServiceClient, id string) { 28 err = function.Delete(client, id) 29 th.AssertNoErr(t, err) 30 }(client, funcUrn) 31 32 syncResp, err := invoke.LaunchSync(client, funcUrn) 33 th.AssertNoErr(t, err) 34 35 tools.PrintResource(t, syncResp) 36 } 37 38 func TestFunctionGraphAsync(t *testing.T) { 39 if funcGraph := os.Getenv("FUNCGRAPH_TEST"); funcGraph == "" { 40 t.Skip("`FUNCGRAPH_TEST`needs to be defined to run this test") 41 } 42 client, err := clients.NewFuncGraphClient() 43 th.AssertNoErr(t, err) 44 45 createResp, _ := createFunctionGraph(t, client) 46 47 funcUrn := strings.TrimSuffix(createResp.FuncURN, ":latest") 48 49 defer func(client *golangsdk.ServiceClient, id string) { 50 err = function.Delete(client, id) 51 th.AssertNoErr(t, err) 52 }(client, funcUrn) 53 54 asyncOpts := map[string]string{ 55 "k": "v", 56 "test": "start", 57 } 58 59 syncResp, err := invoke.LaunchAsync(client, funcUrn, asyncOpts) 60 th.AssertNoErr(t, err) 61 62 tools.PrintResource(t, syncResp) 63 }