mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
Add the test to reproduce the issue even in "make test"
Docker-DCO-1.1-Signed-off-by: Kato Kazuyoshi <kato.kazuyoshi@gmail.com> (github: kzys)
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
@@ -26,6 +28,29 @@ func TestFollowSymLinkNormal(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestFollowSymLinkUnderLinkedDir(t *testing.T) {
|
||||
dir, err := ioutil.TempDir("", "docker-fs-test")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
os.Mkdir(filepath.Join(dir, "realdir"), 0700)
|
||||
os.Symlink("realdir", filepath.Join(dir, "linkdir"))
|
||||
|
||||
linkDir := filepath.Join(dir, "linkdir", "foo")
|
||||
dirUnderLinkDir := filepath.Join(dir, "linkdir", "foo", "bar")
|
||||
os.MkdirAll(dirUnderLinkDir, 0700)
|
||||
|
||||
rewrite, err := FollowSymlinkInScope(dirUnderLinkDir, linkDir)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if rewrite != dirUnderLinkDir {
|
||||
t.Fatalf("Expected %s got %s", dirUnderLinkDir, rewrite)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFollowSymLinkRandomString(t *testing.T) {
|
||||
if _, err := FollowSymlinkInScope("toto", "testdata"); err == nil {
|
||||
t.Fatal("Random string should fail but didn't")
|
||||
|
||||
Reference in New Issue
Block a user