From 51a78405df07fd927b1f6ab0616e4d15f25ef004 Mon Sep 17 00:00:00 2001 From: Anton Nekipelov <226657+anton-107@users.noreply.github.com> Date: Thu, 12 Jun 2025 13:50:37 +0200 Subject: [PATCH 1/2] Add DELETE endpoint for lakeview dashboards in test server --- .../deploy/dashboard/nested-folders/test.toml | 3 --- .../bundle/deploy/dashboard/simple/test.toml | 3 --- .../simple_outside_bundle_root/test.toml | 3 --- .../deploy/dashboard/simple_syncroot/test.toml | 3 --- acceptance/internal/handlers.go | 3 +++ libs/testserver/dashboards.go | 15 +++++++++++++++ 6 files changed, 18 insertions(+), 12 deletions(-) diff --git a/acceptance/bundle/deploy/dashboard/nested-folders/test.toml b/acceptance/bundle/deploy/dashboard/nested-folders/test.toml index a0c54fbc1e..323ae26344 100644 --- a/acceptance/bundle/deploy/dashboard/nested-folders/test.toml +++ b/acceptance/bundle/deploy/dashboard/nested-folders/test.toml @@ -40,6 +40,3 @@ Response.Body = ''' "serialized_dashboard": "{\"pages\":[{\"name\":\"02724bf2\",\"displayName\":\"Dashboard test bundle-deploy-dashboard\",\"pageType\":\"PAGE_TYPE_CANVAS\"}]}" } ''' - -[[Server]] -Pattern = "DELETE /api/2.0/lakeview/dashboards/{dashboard_id}" diff --git a/acceptance/bundle/deploy/dashboard/simple/test.toml b/acceptance/bundle/deploy/dashboard/simple/test.toml index 26b6edd4c7..b5ad021311 100644 --- a/acceptance/bundle/deploy/dashboard/simple/test.toml +++ b/acceptance/bundle/deploy/dashboard/simple/test.toml @@ -33,6 +33,3 @@ Response.Body = ''' "serialized_dashboard": "{\"pages\":[{\"name\":\"02724bf2\",\"displayName\":\"Dashboard test bundle-deploy-dashboard\",\"pageType\":\"PAGE_TYPE_CANVAS\"}]}" } ''' - -[[Server]] -Pattern = "DELETE /api/2.0/lakeview/dashboards/{dashboard_id}" diff --git a/acceptance/bundle/deploy/dashboard/simple_outside_bundle_root/test.toml b/acceptance/bundle/deploy/dashboard/simple_outside_bundle_root/test.toml index 406b398663..2daec5991d 100644 --- a/acceptance/bundle/deploy/dashboard/simple_outside_bundle_root/test.toml +++ b/acceptance/bundle/deploy/dashboard/simple_outside_bundle_root/test.toml @@ -39,6 +39,3 @@ Response.Body = ''' "serialized_dashboard": "{\"pages\":[{\"name\":\"02724bf2\",\"displayName\":\"Dashboard test bundle-deploy-dashboard\",\"pageType\":\"PAGE_TYPE_CANVAS\"}]}" } ''' - -[[Server]] -Pattern = "DELETE /api/2.0/lakeview/dashboards/{dashboard_id}" diff --git a/acceptance/bundle/deploy/dashboard/simple_syncroot/test.toml b/acceptance/bundle/deploy/dashboard/simple_syncroot/test.toml index 406b398663..2daec5991d 100644 --- a/acceptance/bundle/deploy/dashboard/simple_syncroot/test.toml +++ b/acceptance/bundle/deploy/dashboard/simple_syncroot/test.toml @@ -39,6 +39,3 @@ Response.Body = ''' "serialized_dashboard": "{\"pages\":[{\"name\":\"02724bf2\",\"displayName\":\"Dashboard test bundle-deploy-dashboard\",\"pageType\":\"PAGE_TYPE_CANVAS\"}]}" } ''' - -[[Server]] -Pattern = "DELETE /api/2.0/lakeview/dashboards/{dashboard_id}" diff --git a/acceptance/internal/handlers.go b/acceptance/internal/handlers.go index 07f0e01398..1965f02f10 100644 --- a/acceptance/internal/handlers.go +++ b/acceptance/internal/handlers.go @@ -265,6 +265,9 @@ func addDefaultHandlers(server *testserver.Server) { server.Handle("PATCH", "/api/2.0/lakeview/dashboards/{dashboard_id}", func(req testserver.Request) any { return req.Workspace.DashboardUpdate(req) }) + server.Handle("DELETE", "/api/2.0/lakeview/dashboards/{dashboard_id}", func(req testserver.Request) any { + return req.Workspace.DashboardDelete(req) + }) // Pipelines: diff --git a/libs/testserver/dashboards.go b/libs/testserver/dashboards.go index 6e5c26863c..d51d3ceaf2 100644 --- a/libs/testserver/dashboards.go +++ b/libs/testserver/dashboards.go @@ -65,3 +65,18 @@ func (s *FakeWorkspace) DashboardPublish(req Request) Response { }, } } + +func (s *FakeWorkspace) DashboardDelete(req Request) Response { + defer s.LockUnlock()() + + dashboardId := req.Vars["dashboard_id"] + _, ok := s.Dashboards[dashboardId] + if !ok { + return Response{ + StatusCode: 404, + } + } + + delete(s.Dashboards, dashboardId) + return Response{} +} From 50d39f297efd1136b84fd655b57d71f41cd5f871 Mon Sep 17 00:00:00 2001 From: Anton Nekipelov <226657+anton-107@users.noreply.github.com> Date: Thu, 12 Jun 2025 14:50:08 +0200 Subject: [PATCH 2/2] use generic MapDelete --- acceptance/internal/handlers.go | 2 +- libs/testserver/dashboards.go | 15 --------------- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/acceptance/internal/handlers.go b/acceptance/internal/handlers.go index 1965f02f10..85e0f46533 100644 --- a/acceptance/internal/handlers.go +++ b/acceptance/internal/handlers.go @@ -266,7 +266,7 @@ func addDefaultHandlers(server *testserver.Server) { return req.Workspace.DashboardUpdate(req) }) server.Handle("DELETE", "/api/2.0/lakeview/dashboards/{dashboard_id}", func(req testserver.Request) any { - return req.Workspace.DashboardDelete(req) + return testserver.MapDelete(req.Workspace, req.Workspace.Dashboards, req.Vars["dashboard_id"]) }) // Pipelines: diff --git a/libs/testserver/dashboards.go b/libs/testserver/dashboards.go index d51d3ceaf2..6e5c26863c 100644 --- a/libs/testserver/dashboards.go +++ b/libs/testserver/dashboards.go @@ -65,18 +65,3 @@ func (s *FakeWorkspace) DashboardPublish(req Request) Response { }, } } - -func (s *FakeWorkspace) DashboardDelete(req Request) Response { - defer s.LockUnlock()() - - dashboardId := req.Vars["dashboard_id"] - _, ok := s.Dashboards[dashboardId] - if !ok { - return Response{ - StatusCode: 404, - } - } - - delete(s.Dashboards, dashboardId) - return Response{} -}