Repository navigation
Expand file tree
/
Copy pathedge_monitoring_spec.cr
More file actions
49 lines (41 loc) · 1.64 KB
/
Copy pathedge_monitoring_spec.cr
File metadata and controls
49 lines (41 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
require "../helper"
module PlaceOS::Core::Api
describe EdgeMonitoring, tags: "api" do
client = AC::SpecHelper.client
namespace = EdgeMonitoring::NAMESPACE[0]
json_headers = HTTP::Headers{
"Content-Type" => "application/json",
}
describe "POST /cleanup" do
it "responds with success message" do
response = client.post("#{namespace}cleanup", headers: json_headers, body: {hours: 24}.to_json)
response.status_code.should eq 200
result = JSON.parse(response.body)
result["success"].as_bool.should be_true
result["message"].as_s.should contain("24 hours")
result["timestamp"].as_s.should_not be_empty
end
it "accepts custom hours parameter" do
response = client.post("#{namespace}cleanup?hours=48", headers: json_headers)
response.status_code.should eq 200
result = JSON.parse(response.body)
result["success"].as_bool.should be_true
result["message"].as_s.should contain("48 hours")
end
end
describe "GET /summary" do
it "returns error summary statistics" do
response = client.get("#{namespace}summary", headers: json_headers)
response.status_code.should eq 200
result = JSON.parse(response.body)
result["total_edges"].as_i.should be >= 0
result["connected_edges"].as_i.should be >= 0
result["edges_with_errors"].as_i.should be >= 0
result["total_errors_24h"].as_i.should be >= 0
result["total_modules"].as_i.should be >= 0
result["failed_modules"].as_i.should be >= 0
result["timestamp"].as_s.should_not be_empty
end
end
end
end