fix: tests yaml formatting

fix: command memory leak
This commit is contained in:
Tobias Reisinger 2020-05-07 02:38:58 +02:00
parent 10e41ca166
commit dd98af4edc
5 changed files with 175 additions and 133 deletions

View file

@ -74,6 +74,7 @@ command_set_relay_schedule(relay_t *relay)
int result = command_send(controller, COMMAND_CODE_SET_SCHEDULE, payload, payload_size); int result = command_send(controller, COMMAND_CODE_SET_SCHEDULE, payload, payload_size);
controller_free(controller); controller_free(controller);
free(payload);
return result; return result;
} }
@ -102,7 +103,11 @@ command_set_controller_name(controller_t *controller)
LOG_ERROR("an error occurred encoding the data"); LOG_ERROR("an error occurred encoding the data");
return 1; return 1;
} }
return command_send(controller, COMMAND_CODE_SET_NAME, payload, payload_size);
int result = command_send(controller, COMMAND_CODE_SET_NAME, payload, payload_size);
free(payload);
return result;
} }
int int

View file

@ -1,25 +1,23 @@
test_name: Test basic get all requests test_name: Test basic get all requests
stages: stages:
- name: "[test_get_all] get all schedules" - name: "[test_get_all] get all schedules"
request: request:
url: "http://localhost:5000/api/v1/schedules/" url: "http://localhost:5000/api/v1/schedules/"
method: GET method: GET
response: response:
status_code: 200 status_code: 200
- name: "[test_get_all] get all relays" - name: "[test_get_all] get all relays"
skip: True request:
request: url: "http://localhost:5000/api/v1/relays/"
url: "http://localhost:5000/api/v1/relays/" method: GET
method: GET response:
response: status_code: 200
status_code: 200
- name: "[test_get_all] get all controllers" - name: "[test_get_all] get all controllers"
skip: True request:
request: url: "http://localhost:5000/api/v1/controllers/"
url: "http://localhost:5000/api/v1/controllers/" method: GET
method: GET response:
response: status_code: 200
status_code: 200

View file

@ -1,50 +1,50 @@
test_name: Test basic requests test_name: Test basic schedule requests
stages: stages:
- name: "[test_schedules_basic] Make sure we get any response" - name: "[test_schedules_basic] Make sure we get any response"
request: request:
url: "http://localhost:5000/api/v1/schedules/" url: "http://localhost:5000/api/v1/schedules/"
method: GET method: GET
response: response:
status_code: 200 status_code: 200
- name: "[test_schedules_basic] post schedule, expect it to be echoed back" - name: "[test_schedules_basic] post schedule, expect it to be echoed back"
request: request:
method: POST method: POST
url: "http://localhost:5000/api/v1/schedules/" url: "http://localhost:5000/api/v1/schedules/"
json: json:
name: "hello" name: "hello"
periods: periods:
- start: '00:10' - start: "00:10"
end: '00:20' end: "00:20"
- start: '00:30' - start: "00:30"
end: '00:40' end: "00:40"
- start: '00:50' - start: "00:50"
end: '01:00' end: "01:00"
response: response:
status_code: 201 status_code: 201
body: body:
name: "{tavern.request_vars.json.name}" name: "{tavern.request_vars.json.name}"
save: save:
body: body:
returned_name: name returned_name: name
returned_id: id returned_id: id
- name: "[test_schedules_basic] get schedule, check name and some periods" - name: "[test_schedules_basic] get schedule, check name and some periods"
request: request:
method: GET method: GET
url: "http://localhost:5000/api/v1/schedules/{returned_id}" url: "http://localhost:5000/api/v1/schedules/{returned_id}"
response: response:
status_code: 200 status_code: 200
body: body:
name: "{returned_name}" name: "{returned_name}"
- name: "[test_schedules_basic] delete schedule" - name: "[test_schedules_basic] delete schedule"
request: request:
method: DELETE method: DELETE
url: "http://localhost:5000/api/v1/schedules/{returned_id}" url: "http://localhost:5000/api/v1/schedules/{returned_id}"
response: response:
status_code: 200 status_code: 200
- name: "[test_schedules_basic] get deleted schedule, expect 404" - name: "[test_schedules_basic] get deleted schedule, expect 404"
request: request:
method: GET method: GET
url: "http://localhost:5000/api/v1/schedules/{returned_id}" url: "http://localhost:5000/api/v1/schedules/{returned_id}"
response: response:
status_code: 404 status_code: 404

View file

@ -1,66 +1,65 @@
test_name: Test basic requests test_name: Test protected schedules requests
stages: stages:
- name: "[test_schedules_protected] delete protected off schedule; expect forbidden/fail" - name: "[test_schedules_protected] delete protected off schedule; expect forbidden/fail"
request: request:
method: DELETE method: DELETE
url: "http://localhost:5000/api/v1/schedules/off" url: "http://localhost:5000/api/v1/schedules/off"
response: response:
status_code: 403 status_code: 403
- name: "[test_schedules_protected] get protected off schedule" - name: "[test_schedules_protected] get protected off schedule"
request: request:
method: GET method: GET
url: "http://localhost:5000/api/v1/schedules/off" url: "http://localhost:5000/api/v1/schedules/off"
response: response:
status_code: 200 status_code: 200
body: body:
name: "off" name: "off"
periods: [] periods: []
- name: "[test_schedules_protected] overwrite protected off schedule" - name: "[test_schedules_protected] overwrite protected off schedule"
request: request:
method: PUT method: PUT
url: "http://localhost:5000/api/v1/schedules/off" url: "http://localhost:5000/api/v1/schedules/off"
json: json:
name: "turned_off" name: "turned_off"
periods: periods:
- start: "00:10" - start: "00:10"
end: "00:20" end: "00:20"
response: response:
status_code: 200 status_code: 200
body: body:
name: "{tavern.request_vars.json.name}" name: "{tavern.request_vars.json.name}"
periods: [] periods: []
- name: "[test_schedules_protected] delete protected on schedule; expect forbidden/fail"
- name: "[test_schedules_protected] delete protected on schedule; expect forbidden/fail" request:
request: method: DELETE
method: DELETE url: "http://localhost:5000/api/v1/schedules/on"
url: "http://localhost:5000/api/v1/schedules/on" response:
response: status_code: 403
status_code: 403 - name: get protected on schedule
- name: get protected on schedule request:
request: method: GET
method: GET url: "http://localhost:5000/api/v1/schedules/on"
url: "http://localhost:5000/api/v1/schedules/on" response:
response: status_code: 200
status_code: 200 body:
body: name: "on"
name: "on" periods:
periods: - start: "00:00"
- start: "00:00" end: "23:59"
end: "23:59" - name: "[test_schedules_protected] overwrite protected on schedule"
- name: "[test_schedules_protected] overwrite protected on schedule" request:
request: method: PUT
method: PUT url: "http://localhost:5000/api/v1/schedules/on"
url: "http://localhost:5000/api/v1/schedules/on" json:
json: name: "turned_on"
name: "turned_on" periods:
periods: - start: "16:10"
- start: "16:10" end: "17:20"
end: "17:20" response:
response: status_code: 200
status_code: 200 body:
body: name: "{tavern.request_vars.json.name}"
name: "{tavern.request_vars.json.name}" periods:
periods: - start: "00:00"
- start: "00:00" end: "23:59"
end: "23:59"

View file

@ -0,0 +1,40 @@
test_name: Test tagging of schedules and relays
stages:
- name: "[test_tags] post schedule, expect it to be echoed back by tag"
request:
method: POST
url: "http://localhost:5000/api/v1/schedules/"
json:
name: "test tagging schedule"
periods:
- start: "00:50"
end: "01:00"
tags:
- "test_tag_1"
response:
status_code: 201
body:
id: !anystr
name: "{tavern.request_vars.json.name}"
periods:
- start: "00:50"
end: "01:00"
tags:
- "{tavern.request_vars.json.tags[0]}"
save:
body:
returned_name: name
returned_id: id
- name: "[test_tags] get schedule, check name and some periods"
request:
method: GET
url: "http://localhost:5000/api/v1/schedules/tag/test_tag_1"
response:
status_code: 200
body:
- name: "{returned_name}"
id: "{returned_id}"
periods:
- start: "00:50"
end: "01:00"