21 lines
1.3 KiB
C++
21 lines
1.3 KiB
C++
// Route: POST /agent/runtime/delete (dry run unless confirm:true)
|
|
#include "support/GoogleRig.hpp"
|
|
|
|
using namespace molo::example::test;
|
|
|
|
int main() {
|
|
setenv("GOOGLE_CLOUD_PROJECT", "test-project", 1);
|
|
GoogleRig rig(false);
|
|
Fixture f(rig.client);
|
|
auto dry = f.client->post("/agent/runtime/delete", "{\"id\":\"123\",\"force\":true}", "application/json");
|
|
check(dry.status == 200 && contains(dry.body, "\"dry_run\":true") && contains(dry.body, "\"force\":true"), "default is a dry run");
|
|
auto real = f.client->post("/agent/runtime/delete", "{\"id\":\"123\",\"confirm\":true}", "application/json");
|
|
check(real.status == 503 && contains(real.body, "google_not_configured"), "confirmed delete without credential is 503");
|
|
check(f.client->post("/agent/runtime/delete", "{}", "application/json").status == 422, "missing id is 422");
|
|
check(f.client->post("/agent/runtime/delete", "{\"id\":\"1\",\"force\":\"yes\"}", "application/json").status == 422, "non-bool force is 422");
|
|
check(f.client->post("/agent/runtime/delete", "{\"id\":\"1\",\"confirm\":\"yes\"}", "application/json").status == 422, "non-bool confirm is 422");
|
|
check(f.client->get("/agent/runtime/delete").status == 405, "get is 405");
|
|
check(rig.mock->send_count() == 0, "nothing reached Google");
|
|
return finish("agent/runtime/delete");
|
|
}
|