all repos — searchix @ 1d518f42e04712c84dfc168cc7a286aabb56e2ed

Search engine for NixOS, nix-darwin, home-manager and NUR users

feat: limit file operations using os.Root

Alan Pearce
commit

1d518f42e04712c84dfc168cc7a286aabb56e2ed

parent

dec2c516100350a78f0b7116bc6f9d76325e7760

1 file changed, 16 insertions(+), 3 deletions(-)

changed files
M internal/index/search_test.gointernal/index/search_test.go
@@ -9,18 +9,25 @@ "testing"
"time" "alin.ovh/searchix/internal/config" + "alin.ovh/searchix/internal/file" "alin.ovh/searchix/internal/index" "alin.ovh/searchix/internal/nix" "alin.ovh/x/log" ) -const dataRoot = "../../data" +const rootPath = "../../data" func TestSearchGitPackagesFirst(t *testing.T) { log := log.Configure(false) cfg := config.DefaultConfig - read, _, exists, err := index.OpenOrCreate(dataRoot, false, &index.Options{ + root, err := file.CreateAndOpenRoot(rootPath) + if err != nil { + t.Fatal(err) + } + defer root.Close() + + read, _, exists, err := index.OpenOrCreate(root, false, &index.Options{ Logger: log.Named("index"), BatchSize: cfg.Importer.BatchSize, LowMemory: false,
@@ -84,7 +91,13 @@ func TestSearchJujutsuPackagesFirst(t *testing.T) {
log := log.Configure(false) cfg := config.DefaultConfig - read, _, exists, err := index.OpenOrCreate(dataRoot, false, &index.Options{ + root, err := file.CreateAndOpenRoot(rootPath) + if err != nil { + t.Fatal(err) + } + defer root.Close() + + read, _, exists, err := index.OpenOrCreate(root, false, &index.Options{ Logger: log.Named("index"), LowMemory: false, })