PageRenderTime 42ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/vendor/github.com/gophercloud/gophercloud/acceptance/openstack/networking/v2/extensions/subnetpools/subnetpools_test.go

https://gitlab.com/unofficial-mirrors/openshift-origin
Go | 65 lines | 49 code | 14 blank | 2 comment | 16 complexity | f78613bc8ab308a4d0146ebdad79fb94 MD5 | raw file
  1. // +build acceptance networking subnetpools
  2. package v2
  3. import (
  4. "testing"
  5. "github.com/gophercloud/gophercloud/acceptance/clients"
  6. "github.com/gophercloud/gophercloud/acceptance/tools"
  7. "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/subnetpools"
  8. )
  9. func TestSubnetPoolsCRUD(t *testing.T) {
  10. client, err := clients.NewNetworkV2Client()
  11. if err != nil {
  12. t.Fatalf("Unable to create a network client: %v", err)
  13. }
  14. // Create a subnetpool
  15. subnetPool, err := CreateSubnetPool(t, client)
  16. if err != nil {
  17. t.Fatalf("Unable to create a subnetpool: %v", err)
  18. }
  19. defer DeleteSubnetPool(t, client, subnetPool.ID)
  20. tools.PrintResource(t, subnetPool)
  21. newName := tools.RandomString("TESTACC-", 8)
  22. updateOpts := &subnetpools.UpdateOpts{
  23. Name: newName,
  24. }
  25. _, err = subnetpools.Update(client, subnetPool.ID, updateOpts).Extract()
  26. if err != nil {
  27. t.Fatalf("Unable to update the subnetpool: %v", err)
  28. }
  29. newSubnetPool, err := subnetpools.Get(client, subnetPool.ID).Extract()
  30. if err != nil {
  31. t.Fatalf("Unable to get subnetpool: %v", err)
  32. }
  33. tools.PrintResource(t, newSubnetPool)
  34. }
  35. func TestSubnetPoolsList(t *testing.T) {
  36. client, err := clients.NewNetworkV2Client()
  37. if err != nil {
  38. t.Fatalf("Unable to create a network client: %v", err)
  39. }
  40. allPages, err := subnetpools.List(client, nil).AllPages()
  41. if err != nil {
  42. t.Fatalf("Unable to list subnetpools: %v", err)
  43. }
  44. allSubnetPools, err := subnetpools.ExtractSubnetPools(allPages)
  45. if err != nil {
  46. t.Fatalf("Unable to extract subnetpools: %v", err)
  47. }
  48. for _, subnetpool := range allSubnetPools {
  49. tools.PrintResource(t, subnetpool)
  50. }
  51. }