github.com/mook-as/cf-cli@v7.0.0-beta.28.0.20200120190804-b91c115fae48+incompatible/integration/helpers/curl.go (about) 1 package helpers 2 3 import ( 4 "encoding/json" 5 "fmt" 6 "strings" 7 8 . "github.com/onsi/gomega" 9 . "github.com/onsi/gomega/gexec" 10 ) 11 12 // Curl runs a 'cf curl' command with a URL format string, allowing props to be 13 // interpolated into the URL string with fmt.Sprintf. The JSON response is 14 // unmarshaled into given obj. 15 func Curl(obj interface{}, url string, props ...interface{}) { 16 session := CF("curl", fmt.Sprintf(url, props...)) 17 Eventually(session).Should(Exit(0)) 18 rawJSON := strings.TrimSpace(string(session.Out.Contents())) 19 20 err := json.Unmarshal([]byte(rawJSON), &obj) 21 Expect(err).NotTo(HaveOccurred()) 22 }