func TestV3EndpointNone(t *testing.T) { _, actual := openstack.V3EndpointURL(&catalog3, gophercloud.EndpointOpts{ Type: "nope", Availability: gophercloud.AvailabilityPublic, }) expected := &gophercloud.ErrEndpointNotFound{} th.CheckEquals(t, expected.Error(), actual.Error()) }
func TestV3EndpointBadAvailability(t *testing.T) { _, err := openstack.V3EndpointURL(&catalog3, gophercloud.EndpointOpts{ Type: "same", Name: "same", Region: "same", Availability: "wat", }) th.CheckEquals(t, "Unexpected availability in endpoint query: wat", err.Error()) }
func TestV3EndpointMultiple(t *testing.T) { _, err := openstack.V3EndpointURL(&catalog3, gophercloud.EndpointOpts{ Type: "same", Region: "same", Availability: gophercloud.AvailabilityPublic, }) if !strings.HasPrefix(err.Error(), "Discovered 2 matching endpoints:") { t.Errorf("Received unexpected error: %v", err) } }
func TestV3EndpointExact(t *testing.T) { expectedURLs := map[gophercloud.Availability]string{ gophercloud.AvailabilityPublic: "https://public.correct.com/", gophercloud.AvailabilityAdmin: "https://admin.correct.com/", gophercloud.AvailabilityInternal: "https://internal.correct.com/", } for availability, expected := range expectedURLs { actual, err := openstack.V3EndpointURL(&catalog3, gophercloud.EndpointOpts{ Type: "same", Name: "same", Region: "same", Availability: availability, }) th.AssertNoErr(t, err) th.CheckEquals(t, expected, actual) } }