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:
parent
14e1a2345d
commit
e3e078ca2f
|
@ -1,6 +1,8 @@
|
||||||
package utils
|
package utils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
"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) {
|
func TestFollowSymLinkRandomString(t *testing.T) {
|
||||||
if _, err := FollowSymlinkInScope("toto", "testdata"); err == nil {
|
if _, err := FollowSymlinkInScope("toto", "testdata"); err == nil {
|
||||||
t.Fatal("Random string should fail but didn't")
|
t.Fatal("Random string should fail but didn't")
|
||||||
|
|
Loading…
Reference in New Issue