add: tests and test_script
This commit is contained in:
parent
51ab1d7982
commit
2a4e0e1075
5 changed files with 83 additions and 14 deletions
controllers
|
@ -126,15 +126,6 @@ void
|
|||
schedules::put_one_by_id(const HttpRequestPtr &req, std::function<void(const HttpResponsePtr &)> &&callback,
|
||||
const std::string &schedule_id_str)
|
||||
{
|
||||
if(strcmp(schedule_id_str.c_str(), "off") == 0 || strcmp(schedule_id_str.c_str(), "on") == 0)
|
||||
{
|
||||
auto resp = HttpResponse::newHttpResponse();
|
||||
resp->setStatusCode(k403Forbidden);
|
||||
callback(resp);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
uuid_t schedule_id;
|
||||
if(schedule_dbo::parse_id(schedule_id_str.c_str(), schedule_id))
|
||||
{
|
||||
|
@ -151,8 +142,13 @@ schedules::put_one_by_id(const HttpRequestPtr &req, std::function<void(const Htt
|
|||
{
|
||||
strncpy(schedules[0]->name, body["name"].asCString(), 127);
|
||||
schedules[0]->name[127] = '\0';
|
||||
delete schedules[0]->periods;
|
||||
schedules[0]->periods = helpers::parse_periods(body["periods"]);
|
||||
|
||||
// if neither "off" nor "on" allow overwrite of periods
|
||||
if(strcmp(schedule_id_str.c_str(), "off") && strcmp(schedule_id_str.c_str(), "on"))
|
||||
{
|
||||
delete schedules[0]->periods;
|
||||
schedules[0]->periods = helpers::parse_periods(body["periods"]);
|
||||
}
|
||||
|
||||
if(!schedules[0]->update())
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue