create db links if not exist for all configured repos

This commit is contained in:
2026-05-08 11:46:25 -06:00
parent 7d2324ca56
commit 5aca006249
2 changed files with 50 additions and 0 deletions
+27
View File
@@ -7,6 +7,8 @@ import (
"io"
"net/http"
"net/http/httptest"
"os"
"path/filepath"
"testing"
"time"
)
@@ -206,3 +208,28 @@ func TestFetchRetryNonExist(t *testing.T) {
t.Errorf("expected 404 got %d", upstreamErr.StatusCode)
}
}
func TestCreateSymlinks(t *testing.T) {
repos := []string{"core", "extra"}
tmp := t.TempDir()
cr, err := os.OpenRoot(tmp)
if err != nil {
t.Fatalf("unable to create tmp dir: %v", err)
}
if err := checkSymLinks(cr, repos); err != nil {
t.Fatalf("error creating links: %v", err)
}
for _, repo := range repos {
lnfile := filepath.Join(repo, "os/x86_64", repo+".db")
expected := lnfile + ".tar.gz"
lnval, err := cr.Readlink(lnfile)
if err != nil {
t.Errorf("%s has no link: %v", repo, err)
}
if lnval != expected {
t.Errorf("expected %s got %s", expected, lnval)
}
}
}