diff options
author | n-peugnet <n.peugnet@free.fr> | 2021-09-23 01:20:25 +0200 |
---|---|---|
committer | n-peugnet <n.peugnet@free.fr> | 2021-09-23 01:20:25 +0200 |
commit | b3b6e4bf6c9a14514bcfb8406d9cc86d9d18bd06 (patch) | |
tree | 65f792759394d1bc08e18d6987e4da1887990376 /repo_test.go | |
parent | cac8795d33cd52d362e02590b4df4ccd9b96ff71 (diff) | |
download | dna-backup-b3b6e4bf6c9a14514bcfb8406d9cc86d9d18bd06.tar.gz dna-backup-b3b6e4bf6c9a14514bcfb8406d9cc86d9d18bd06.zip |
better tests (util/io subtests + check log output)
Diffstat (limited to 'repo_test.go')
-rw-r--r-- | repo_test.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/repo_test.go b/repo_test.go index 52da9ae..6ab7cb0 100644 --- a/repo_test.go +++ b/repo_test.go @@ -7,6 +7,7 @@ import ( "io/ioutil" "os" "path/filepath" + "strings" "testing" "github.com/n-peugnet/dna-backup/logger" @@ -128,6 +129,9 @@ func TestReadFiles3(t *testing.T) { } func TestNoSuchFile(t *testing.T) { + var output bytes.Buffer + logger.SetOutput(&output) + defer logger.SetOutput(os.Stderr) tmpDir := t.TempDir() os.Symlink("./notexisting", filepath.Join(tmpDir, "linknotexisting")) var buff bytes.Buffer @@ -136,6 +140,9 @@ func TestNoSuchFile(t *testing.T) { 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) + } } func TestLoadChunks(t *testing.T) { |