Create test symlinks dynamically (#2681)

Some tools dislike having questionable symlinks in git repository so we
must create this symlinks dynamically in the test instead of having it
committed into the repository.

Signed-off-by: Matej Vašek <matejvasek@gmail.com>
This commit is contained in:
Matej Vašek 2025-01-31 17:24:57 +01:00 committed by GitHub
parent 4b1cc39731
commit d20eb9685f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 3 deletions

View File

@ -1,6 +1,8 @@
package oci
import (
"errors"
"os"
"path/filepath"
"runtime"
"testing"
@ -10,7 +12,16 @@ import (
// links which are absolute or refer to targets outside the given root, in
// addition to the basic job of returning the value of reading the link.
func Test_validatedLinkTarget(t *testing.T) {
root := "testdata/test-links"
root := filepath.Join("testdata", "test-links")
err := os.Symlink("/var/example/absolute/link", filepath.Join(root, "absoluteLink"))
if err != nil && !errors.Is(err, os.ErrExist) {
t.Fatal(err)
}
err = os.Symlink("c://some/absolute/path", filepath.Join(root, "absoluteLinkWindows"))
if err != nil && !errors.Is(err, os.ErrExist) {
t.Fatal(err)
}
// Windows-specific absolute link and link target values:
absoluteLink := "absoluteLink"

View File

@ -1 +0,0 @@
/var/example/absolute/link

View File

@ -1 +0,0 @@
c://some/absolute/path