droboticflow/internal/api/object_storage_browser_test.go
eust-w 43326d6a5e feat(platform): land workflow, data tooling, and docs updates
Include the accumulated workflow scheduling, run history, subtree rerun, operator UI, deployment, data asset, object storage, database browser, and documentation changes currently in the worktree.
2026-04-24 12:29:46 +08:00

38 lines
1.1 KiB
Go

package api
import (
"net/http"
"net/http/httptest"
"strings"
"testing"
"github.com/baidubce/bce-sdk-go/bce"
)
func TestExactObjectStorageKeyPreservesTrailingSlash(t *testing.T) {
if got := exactObjectStorageKey(" algo/nested/ "); got != "algo/nested/" {
t.Fatalf("exactObjectStorageKey preserved key = %q, want %q", got, "algo/nested/")
}
}
func TestIsBOSNoSuchKeyRecognizesServiceError(t *testing.T) {
err := bce.NewBceServiceError("NoSuchKey", "The specified key does not exist.", "req-1", http.StatusNotFound)
if !isBOSNoSuchKey(err) {
t.Fatalf("expected NoSuchKey to be recognized")
}
}
func TestRenderObjectStorageWriteErrorTreatsBOSNoSuchKeyAsNotFound(t *testing.T) {
recorder := httptest.NewRecorder()
err := bce.NewBceServiceError("NoSuchKey", "The specified key does not exist.", "req-2", http.StatusNotFound)
renderObjectStorageWriteError(recorder, err)
if recorder.Code != http.StatusNotFound {
t.Fatalf("status = %d, want %d", recorder.Code, http.StatusNotFound)
}
if !strings.Contains(recorder.Body.String(), "NoSuchKey") {
t.Fatalf("expected response to include NoSuchKey, got %s", recorder.Body.String())
}
}