aboutsummaryrefslogtreecommitdiff
path: root/repo_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'repo_test.go')
-rw-r--r--repo_test.go23
1 files changed, 20 insertions, 3 deletions
diff --git a/repo_test.go b/repo_test.go
index 6ab7cb0..2d1c6e2 100644
--- a/repo_test.go
+++ b/repo_test.go
@@ -128,20 +128,37 @@ func TestReadFiles3(t *testing.T) {
chunkCompare(t, dataDir, repo, files, chunkCount)
}
-func TestNoSuchFile(t *testing.T) {
+func TestSymlinks(t *testing.T) {
var output bytes.Buffer
logger.SetOutput(&output)
defer logger.SetOutput(os.Stderr)
tmpDir := t.TempDir()
+ extDir := t.TempDir()
+ extNotWritable := filepath.Join(extDir, "notwritable")
+ f, err := os.OpenFile(extNotWritable, os.O_CREATE, 0000)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if err := f.Close(); err != nil {
+ t.Fatal(err)
+ }
+ os.Symlink(extDir, filepath.Join(tmpDir, "linktodir"))
os.Symlink("./notexisting", filepath.Join(tmpDir, "linknotexisting"))
+ os.Symlink(extNotWritable, filepath.Join(tmpDir, "linknotwritable"))
var buff bytes.Buffer
files := listFiles(tmpDir)
testutils.AssertLen(t, 1, files, "Files")
concatFiles(&files, utils.NopCloser(&buff))
testutils.AssertLen(t, 0, files, "Files")
testutils.AssertLen(t, 0, buff.Bytes(), "Buffer")
- if !strings.Contains(output.String(), "linknotexisting") {
- t.Errorf("log should contain a warning, actual %q", &output)
+ if !strings.Contains(output.String(), "linktodir") {
+ t.Errorf("log should contain a warning for linktodir, actual %q", &output)
+ }
+ if !strings.Contains(output.String(), "notexisting") {
+ t.Errorf("log should contain a warning for notexisting, actual %q", &output)
+ }
+ if !strings.Contains(output.String(), "linknotwritable") {
+ t.Errorf("log should contain a warning for linknotwritable, actual %q", &output)
}
}