fix(s3): encode multipart fixture paths (#3074)

test(s3): encode multipart fixture paths

- Serialize the Local storage addition instead of interpolating filesystem paths into JSON.
- Keep multipart fixture behavior portable across Windows and Linux.

Co-authored-by: nostalume <nostalucent@gmail.com>
Co-authored-by: Codex <267193182+codex@users.noreply.github.com>
This commit is contained in:
Nostalgia
2026-09-14 20:30:17 +08:00
committed by GitHub
parent f18b4acc76
commit 5447ecb072
+12 -1
View File
@@ -3,6 +3,7 @@ package s3
import (
"bytes"
"context"
"encoding/json"
"errors"
"os"
"path/filepath"
@@ -67,11 +68,21 @@ func setupMultipartBackend(t *testing.T) (*s3Backend, string) {
t.Fatalf("mkdir local root: %v", err)
}
t.Cleanup(func() { _ = os.RemoveAll(localRoot) })
addition, err := json.Marshal(struct {
RootFolderPath string `json:"root_folder_path"`
Thumbnail bool `json:"thumbnail"`
}{
RootFolderPath: localRoot,
Thumbnail: false,
})
if err != nil {
t.Fatalf("marshal local storage addition: %v", err)
}
_, err = op.CreateStorage(ctx, model.Storage{
Driver: "Local",
MountPath: mount,
Addition: `{"root_folder_path":"` + localRoot + `","thumbnail":false}`,
Addition: string(addition),
})
if err != nil {
t.Fatalf("create local storage: %+v", err)