aboutsummaryrefslogtreecommitdiff
path: root/repo_test.go
diff options
context:
space:
mode:
authorn-peugnet <n.peugnet@free.fr>2021-09-23 16:24:02 +0200
committern-peugnet <n.peugnet@free.fr>2021-09-23 17:45:08 +0200
commite4f6bf0d972b8e851a6fcaa20c1f305680f61884 (patch)
tree483daf9820dee3a8e658b47082841e1ef12ef99b /repo_test.go
parent2835b35221cb831c4836531204d96e3c5c2d4b13 (diff)
downloaddna-backup-e4f6bf0d972b8e851a6fcaa20c1f305680f61884.tar.gz
dna-backup-e4f6bf0d972b8e851a6fcaa20c1f305680f61884.zip
better error handling and start checking symlinks
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)
}
}