func TestV2EndpointNone(t *testing.T) { _, actual := openstack.V2EndpointURL(&catalog2, gophercloud.EndpointOpts{ Type: "nope", Availability: gophercloud.AvailabilityPublic, }) expected := &gophercloud.ErrEndpointNotFound{} th.CheckEquals(t, expected.Error(), actual.Error()) }
func TestV2EndpointBadAvailability(t *testing.T) { _, err := openstack.V2EndpointURL(&catalog2, gophercloud.EndpointOpts{ Type: "same", Name: "same", Region: "same", Availability: "wat", }) th.CheckEquals(t, "Unexpected availability in endpoint query: wat", err.Error()) }
func TestV2EndpointMultiple(t *testing.T) { _, err := openstack.V2EndpointURL(&catalog2, 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 TestV2EndpointExact(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.V2EndpointURL(&catalog2, gophercloud.EndpointOpts{ Type: "same", Name: "same", Region: "same", Availability: availability, }) th.AssertNoErr(t, err) th.CheckEquals(t, expected, actual) } }