github.com/gophercloud/gophercloud@v1.11.0/internal/acceptance/openstack/compute/v2/limits_test.go (about) 1 //go:build acceptance || compute || limits 2 // +build acceptance compute limits 3 4 package v2 5 6 import ( 7 "strings" 8 "testing" 9 10 "github.com/gophercloud/gophercloud/internal/acceptance/clients" 11 "github.com/gophercloud/gophercloud/internal/acceptance/tools" 12 "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/limits" 13 th "github.com/gophercloud/gophercloud/testhelper" 14 ) 15 16 func TestLimits(t *testing.T) { 17 client, err := clients.NewComputeV2Client() 18 th.AssertNoErr(t, err) 19 20 limits, err := limits.Get(client, nil).Extract() 21 th.AssertNoErr(t, err) 22 23 tools.PrintResource(t, limits) 24 25 th.AssertEquals(t, limits.Absolute.MaxPersonalitySize, 10240) 26 } 27 28 func TestLimitsForTenant(t *testing.T) { 29 clients.RequireAdmin(t) 30 31 client, err := clients.NewComputeV2Client() 32 th.AssertNoErr(t, err) 33 34 // I think this is the easiest way to get the tenant ID while being 35 // agnostic to Identity v2 and v3. 36 // Technically we're just returning the limits for ourselves, but it's 37 // the fact that we're specifying a tenant ID that is important here. 38 endpointParts := strings.Split(client.Endpoint, "/") 39 tenantID := endpointParts[4] 40 41 getOpts := limits.GetOpts{ 42 TenantID: tenantID, 43 } 44 45 limits, err := limits.Get(client, getOpts).Extract() 46 th.AssertNoErr(t, err) 47 48 tools.PrintResource(t, limits) 49 50 th.AssertEquals(t, limits.Absolute.MaxPersonalitySize, 10240) 51 }