diff options
author | n-peugnet <n.peugnet@free.fr> | 2021-09-29 18:00:21 +0200 |
---|---|---|
committer | n-peugnet <n.peugnet@free.fr> | 2021-09-29 18:00:21 +0200 |
commit | d895b2b315e1a3fe37ca9afd140d6cc791ffc868 (patch) | |
tree | 7dc02cc2b423c6c147821ff87589497fcdc158bb /repo_test.go | |
parent | c2cc8f8a6fb65488f19a5addf47d83e19aff6f4b (diff) | |
download | dna-backup-d895b2b315e1a3fe37ca9afd140d6cc791ffc868.tar.gz dna-backup-d895b2b315e1a3fe37ca9afd140d6cc791ffc868.zip |
support symlinks if it is internal to source
adapt tests
Diffstat (limited to 'repo_test.go')
-rw-r--r-- | repo_test.go | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/repo_test.go b/repo_test.go index 35b3101..b97ebae 100644 --- a/repo_test.go +++ b/repo_test.go @@ -178,12 +178,26 @@ func TestSymlinks(t *testing.T) { defer logger.SetOutput(os.Stderr) tmpDir := t.TempDir() extDir := t.TempDir() - os.Symlink(extDir, filepath.Join(tmpDir, "linktodir")) + f, err := os.Create(filepath.Join(tmpDir, "existing")) + if err != nil { + t.Fatal(err) + } + if err = f.Close(); err != nil { + t.Fatal(err) + } + os.Symlink(extDir, filepath.Join(tmpDir, "linkexternal")) os.Symlink("./notexisting", filepath.Join(tmpDir, "linknotexisting")) + os.Symlink("./existing", filepath.Join(tmpDir, "linkexisting")) files := listFiles(tmpDir) - testutils.AssertLen(t, 0, files, "Files") - if !strings.Contains(output.String(), "linktodir") { - t.Errorf("log should contain a warning for linktodir, actual %q", &output) + testutils.AssertLen(t, 2, files, "Files") + if files[0].Link != "" { + t.Error("linkexisting should not be a link, actual:", files[0].Link) + } + if files[1].Link != "existing" { + t.Error("linkexisting should point to 'existing', actual:", files[1].Link) + } + if !strings.Contains(output.String(), "linkexternal") { + t.Errorf("log should contain a warning for linkexternal, actual %q", &output) } if !strings.Contains(output.String(), "notexisting") { t.Errorf("log should contain a warning for notexisting, actual %q", &output) @@ -325,6 +339,8 @@ func TestCommitZlib(t *testing.T) { } func TestRestore(t *testing.T) { + logger.SetLevel(2) + defer logger.SetLevel(4) dest := t.TempDir() source := filepath.Join("testdata", "repo_8k") expected := filepath.Join("testdata", "logs") @@ -339,6 +355,8 @@ func TestRestore(t *testing.T) { } func TestRestoreZlib(t *testing.T) { + logger.SetLevel(2) + defer logger.SetLevel(4) dest := t.TempDir() source := filepath.Join("testdata", "repo_8k_zlib") expected := filepath.Join("testdata", "logs") @@ -353,6 +371,8 @@ func TestRestoreZlib(t *testing.T) { } func TestRoundtrip(t *testing.T) { + logger.SetLevel(2) + defer logger.SetLevel(4) temp := t.TempDir() dest := t.TempDir() source := filepath.Join("testdata", "logs") |