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:
parent
0f48220225
commit
3b3d22d91e
1 changed files with 24 additions and 4 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue