Skip to content

Commit

Permalink
Create test symlinks dynamically
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
matejvasek committed Oct 3, 2024
1 parent 07c99e7 commit c8ff2c4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
13 changes: 12 additions & 1 deletion pkg/oci/containerize_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package oci

import (
"errors"
"os"
"path/filepath"
"runtime"
"testing"
Expand All @@ -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"
Expand Down
1 change: 0 additions & 1 deletion pkg/oci/testdata/test-links/absoluteLink

This file was deleted.

1 change: 0 additions & 1 deletion pkg/oci/testdata/test-links/absoluteLinkWindows

This file was deleted.

0 comments on commit c8ff2c4

Please sign in to comment.