From fe96f80de184bdeb4ea3969fc0c99ff57f49b09c Mon Sep 17 00:00:00 2001 From: Denis Bilenko Date: Mon, 10 Feb 2025 16:33:32 +0100 Subject: [PATCH] testserver: auto-create directories when importing a file --- libs/testserver/fake_workspace.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libs/testserver/fake_workspace.go b/libs/testserver/fake_workspace.go index 4e943f828..d7c92515b 100644 --- a/libs/testserver/fake_workspace.go +++ b/libs/testserver/fake_workspace.go @@ -4,6 +4,7 @@ import ( "bytes" "encoding/json" "fmt" + "net/http" "sort" "strconv" "strings" @@ -81,6 +82,17 @@ func (s *FakeWorkspace) WorkspaceFilesImportFile(path string, body []byte) { path = "/" + path } s.files[path] = body + + for { + p = path.Dir(p) + if p == "" || p == "/" { + break + } + + s.directories[p] = true + } + + return "{}", http.StatusOK } func (s *FakeWorkspace) JobsCreate(request jobs.CreateJob) Response {