diff --git a/helpers/v3_helpers/routes.go b/helpers/v3_helpers/routes.go index 9c4e4e1e2..2603adb78 100644 --- a/helpers/v3_helpers/routes.go +++ b/helpers/v3_helpers/routes.go @@ -1,8 +1,8 @@ package v3_helpers import ( + "encoding/json" "fmt" - "regexp" "github.com/cloudfoundry/cf-test-helpers/v2/cf" . "github.com/onsi/gomega" @@ -13,7 +13,14 @@ func GetRouteGuid(hostname string) string { routeQuery := fmt.Sprintf("/v3/routes?hosts=%s", hostname) getRoutesCurl := cf.Cf("curl", routeQuery) Expect(getRoutesCurl.Wait()).To(Exit(0)) + routesJSON := struct { + Resources []struct { + Guid string `json:"guid"` + } `json:"resources"` + }{} + bytes := getRoutesCurl.Out.Contents() - routeGuidRegex := regexp.MustCompile(`\s+"guid": "(.+)"`) - return routeGuidRegex.FindStringSubmatch(string(getRoutesCurl.Out.Contents()))[1] + json.Unmarshal(bytes, &routesJSON) + + return routesJSON.Resources[0].Guid }