github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/acceptance/openstack/fgs/v2/utils_test.go (about) 1 package v2 2 3 import ( 4 "os" 5 "strings" 6 "testing" 7 "time" 8 9 golangsdk "github.com/opentelekomcloud/gophertelekomcloud" 10 "github.com/opentelekomcloud/gophertelekomcloud/acceptance/clients" 11 "github.com/opentelekomcloud/gophertelekomcloud/acceptance/tools" 12 "github.com/opentelekomcloud/gophertelekomcloud/openstack/fgs/v2/function" 13 "github.com/opentelekomcloud/gophertelekomcloud/openstack/fgs/v2/util" 14 th "github.com/opentelekomcloud/gophertelekomcloud/testhelper" 15 ) 16 17 func TestFunctionGraphUtils(t *testing.T) { 18 client, err := clients.NewFuncGraphClient() 19 th.AssertNoErr(t, err) 20 21 createResp, _ := createFunctionGraph(t, client) 22 23 funcUrn := strings.TrimSuffix(createResp.FuncURN, ":latest") 24 25 defer func(client *golangsdk.ServiceClient, id string) { 26 err = function.Delete(client, id) 27 th.AssertNoErr(t, err) 28 }(client, funcUrn) 29 30 timestamp := time.Now().Add(-5 * time.Minute).Format(time.RFC3339) 31 32 listPeriod, err := util.ListStatsPeriod(client, funcUrn, timestamp) 33 th.AssertNoErr(t, err) 34 tools.PrintResource(t, listPeriod) 35 36 // API doesn't work 37 // th.AssertNoErr(t, util.EnableFuncLts(client)) 38 39 // getLts, err := util.GetFuncLts(client, funcUrn) 40 // th.AssertNoErr(t, err) 41 } 42 43 func TestFunctionGraphStatList(t *testing.T) { 44 client, err := clients.NewFuncGraphClient() 45 th.AssertNoErr(t, err) 46 47 listStats, err := util.ListStats(client, util.ListStatsOpts{ 48 Filter: "monthly_report", 49 }) 50 th.AssertNoErr(t, err) 51 tools.PrintResource(t, listStats) 52 } 53 54 func TestFunctionGraphTemplate(t *testing.T) { 55 t.Skip("API not published") 56 templateID := os.Getenv("TEMPLATE_ID") 57 58 client, err := clients.NewFuncGraphClient() 59 th.AssertNoErr(t, err) 60 61 templateResp, err := util.GetFuncTemplate(client, templateID) 62 th.AssertNoErr(t, err) 63 tools.PrintResource(t, templateResp) 64 }