Openstatus www.openstatus.dev
6
fork

Configure Feed

Select the types of activity you want to include in your feed.

๐Ÿ› partial monitor (#1288)

* ๐Ÿ› partial

* ci: apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>

authored by

Thibault Le Ouay
autofix-ci[bot]
and committed by
GitHub
86a17b39 b0058e30

+11 -19
+2 -7
apps/server/src/routes/v1/monitors/put.test.ts
··· 1 1 import { expect, test } from "bun:test"; 2 2 3 3 import { app } from "@/index"; 4 - import { MonitorSchema } from "./schema"; 5 4 6 - test("update the monitor", async () => { 5 + test("Partial update the monitor", async () => { 7 6 const res = await app.request("/v1/monitor/1", { 8 7 method: "PUT", 9 8 headers: { ··· 15 14 }), 16 15 }); 17 16 18 - const result = MonitorSchema.safeParse(await res.json()); 19 - 20 - expect(res.status).toBe(200); 21 - expect(result.success).toBe(true); 22 - expect(result.data?.name).toBe("New Name"); 17 + expect(res.status).toBe(400); 23 18 }); 24 19 25 20 test("invalid monitor id should return 404", async () => {
+9 -12
apps/server/src/routes/v1/monitors/put.ts
··· 28 28 description: "The monitor to update", 29 29 content: { 30 30 "application/json": { 31 - schema: HTTPMonitorSchema.partial().or(TCPMonitorSchema.partial()), 31 + schema: HTTPMonitorSchema.or(TCPMonitorSchema), 32 32 }, 33 33 }, 34 34 }, ··· 91 91 } 92 92 93 93 if (_monitor.jobType === "http") { 94 - const data = HTTPMonitorSchema.partial().parse(input); 94 + const data = HTTPMonitorSchema.parse(input); 95 95 const { request, regions, assertions, otelHeaders, ...rest } = data; 96 96 97 97 const headers = data?.request?.headers ··· 114 114 .update(monitor) 115 115 .set({ 116 116 ...rest, 117 - regions: regions ? regions.join(",") : _monitor.regions, 118 - headers: headersEntries 119 - ? JSON.stringify(headersEntries) 120 - : _monitor.headers, 117 + regions: regions.join(","), 118 + headers: headersEntries ? JSON.stringify(headersEntries) : undefined, 121 119 otelHeaders: otelHeadersEntries 122 120 ? JSON.stringify(otelHeadersEntries) 123 - : _monitor.otelHeaders, 124 - assertions: 125 - assert.length > 0 ? serialize(assert) : _monitor.assertions, 121 + : undefined, 122 + assertions: assert.length > 0 ? serialize(assert) : undefined, 126 123 timeout: input.timeout || 45000, 127 124 updatedAt: new Date(), 128 125 }) ··· 133 130 return c.json(r, 200); 134 131 } 135 132 if (_monitor.jobType === "tcp") { 136 - const data = TCPMonitorSchema.partial().parse(input); 133 + const data = TCPMonitorSchema.parse(input); 137 134 const { request, regions, otelHeaders, ...rest } = data; 138 135 139 136 const otelHeadersEntries = otelHeaders ··· 147 144 .update(monitor) 148 145 .set({ 149 146 ...rest, 150 - regions: regions ? regions.join(",") : _monitor.regions, 147 + regions: regions.join(","), 151 148 otelHeaders: otelHeadersEntries 152 149 ? JSON.stringify(otelHeadersEntries) 153 - : _monitor.otelHeaders, 150 + : undefined, 154 151 timeout: input.timeout || 45000, 155 152 updatedAt: new Date(), 156 153 })