rcm tests: add get status test

This is a very basic test to get the status of a single compose. It will
evolve as the API gains support for Koji builds.
This commit is contained in:
Martin Sehnoutka 2020-03-09 12:32:33 +01:00 committed by Tom Gundersen
parent 0f48220225
commit 3b3d22d91e

View file

@ -29,16 +29,16 @@ func main() {
// Case 1: POST request
resp, err := http.Post(socket + endpoint, "application/json", strings.NewReader(submit_body))
var reply struct {
UUID uuid.UUID `json:"compose_id"`
}
if err != nil {
log.Fatal("Failed to submit a compose")
log.Fatal("Failed to submit a compose: ", err.Error())
}
if resp.StatusCode != 200 {
log.Print("Error: the ", endpoint, " returned non 200 status. Full response: ", resp)
failed = true
} else {
var reply struct {
UUID uuid.UUID `json:"compose_id"`
}
err = json.NewDecoder(resp.Body).Decode(&reply)
if err != nil {
log.Fatal("Failed to decode JSON response from ", endpoint)
@ -46,6 +46,26 @@ func main() {
log.Print("Success: the ", endpoint, " returned compose UUID: ", reply.UUID)
}
// Case 2: GET status
statusEndpoint := endpoint + "/" + reply.UUID.String()
resp, err = http.Get(socket + statusEndpoint)
var status struct {
Status string `json:"status"`
}
if err != nil {
log.Fatal("Failed to get a status: ", err.Error())
}
if resp.StatusCode != 200 {
log.Print("Error: the ", endpoint, " returned non 200 status. Full response: ", resp)
failed = true
} else {
err = json.NewDecoder(resp.Body).Decode(&status)
if err != nil {
log.Fatal("Failed to decode JSON response from ", endpoint)
}
log.Print("Success: the ", statusEndpoint, " returned status: ", status.Status)
}
if failed {
os.Exit(1)