From d6f93b022d84d3247bbed15b94f167ffa6b537bc Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Fri, 2 Jul 2021 17:36:52 +0100 Subject: [PATCH] add tests which validate the /status/latest call. The URL which returns the latest status for all the devices at once is validated. The tests are not extensive. They just check to make sure all the intended device are present and the last device on the list is 'device 6'. If any of the device names change or 'device 6' is not the last device, it means the API has changed. --- tests/main.lisp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/main.lisp b/tests/main.lisp index 9fd3aa1..f89874c 100644 --- a/tests/main.lisp +++ b/tests/main.lisp @@ -239,3 +239,17 @@ ;; data (manually most likely) which should result in this failing ;; because Ratify will return the parsed timestamp and not `NIL'. (is (equal (ratify:datetime-p (cdaddr data)) nil)))) ; time value. + +(fiveam:test all-device-status-data + :description "Validates the status data produced when all status + data for all devices is requested in the same API call." + (let ((data (ritherdon-rest:parse-request "/status/latest"))) + (is (= 6 (length data))) + (is-true (consp data)) + (is (equal ':|DEVICE 1| (car (first data)))) + (is (equal ':|DEVICE 2| (car (second data)))) + (is (equal ':|DEVICE 3| (car (third data)))) + (is (equal ':|DEVICE 4| (car (fourth data)))) + (is (equal ':|DEVICE 5| (car (fifth data)))) + ;; if 6 not last a big change has occurred. + (is (equal ':|DEVICE 6| (caar (last data))))))