package storage

import (
	"context"
	"os"
	"path/filepath"
	"testing"
)

func TestLocalDeletePrefixRejectsEmptyPrefix(t *testing.T) {
	root := t.TempDir()
	sentinel := filepath.Join(root, "keep.txt")
	if err := os.WriteFile(sentinel, []byte("keep"), 0o600); err != nil {
		t.Fatalf("write sentinel: %v", err)
	}
	storage := &fileStorage{root: root, urlPrefix: "/files"}

	if err := storage.DeletePrefix(context.Background(), " /"); err == nil {
		t.Fatal("DeletePrefix() accepted an empty prefix")
	}
	if _, err := os.Stat(sentinel); err != nil {
		t.Fatalf("sentinel was removed: %v", err)
	}
}
