availabilityzones_test.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // +build acceptance compute availabilityzones
  2. package v2
  3. import (
  4. "testing"
  5. "devel.mephi.ru/iacherepanov/openstack-gophercloud/acceptance/clients"
  6. "devel.mephi.ru/iacherepanov/openstack-gophercloud/acceptance/tools"
  7. "devel.mephi.ru/iacherepanov/openstack-gophercloud/openstack/compute/v2/extensions/availabilityzones"
  8. th "devel.mephi.ru/iacherepanov/openstack-gophercloud/testhelper"
  9. )
  10. func TestAvailabilityZonesList(t *testing.T) {
  11. client, err := clients.NewComputeV2Client()
  12. th.AssertNoErr(t, err)
  13. allPages, err := availabilityzones.List(client).AllPages()
  14. th.AssertNoErr(t, err)
  15. availabilityZoneInfo, err := availabilityzones.ExtractAvailabilityZones(allPages)
  16. th.AssertNoErr(t, err)
  17. var found bool
  18. for _, zoneInfo := range availabilityZoneInfo {
  19. tools.PrintResource(t, zoneInfo)
  20. if zoneInfo.ZoneName == "nova" {
  21. found = true
  22. }
  23. }
  24. th.AssertEquals(t, found, true)
  25. }
  26. func TestAvailabilityZonesListDetail(t *testing.T) {
  27. clients.RequireAdmin(t)
  28. client, err := clients.NewComputeV2Client()
  29. th.AssertNoErr(t, err)
  30. allPages, err := availabilityzones.ListDetail(client).AllPages()
  31. th.AssertNoErr(t, err)
  32. availabilityZoneInfo, err := availabilityzones.ExtractAvailabilityZones(allPages)
  33. th.AssertNoErr(t, err)
  34. var found bool
  35. for _, zoneInfo := range availabilityZoneInfo {
  36. tools.PrintResource(t, zoneInfo)
  37. if zoneInfo.ZoneName == "nova" {
  38. found = true
  39. }
  40. }
  41. th.AssertEquals(t, found, true)
  42. }