lib/model: Improve filesystem operations during tests (fixes #5422)

* lib/fs, lib/model: Improve filesystem operations during tests (fixes #5422)

Introduces MustFilesystem that panics on errors and should be used for operations
during testing which must never fail.
Create temporary directories outside of testdata.

* don't do a filesystem, just a wrapper around os for testing

* fix copyright
This commit is contained in:
Simon Frei
2019-01-11 13:56:05 +01:00
committed by Audrius Butkevicius
parent 24ffd8be99
commit 0b03b6a9ec
7 changed files with 380 additions and 236 deletions

View File

@@ -8,7 +8,6 @@ package model
import (
"fmt"
"os"
"path/filepath"
"runtime"
"testing"
@@ -52,10 +51,12 @@ func expectTimeout(w *events.Subscription, t *testing.T) {
}
func TestProgressEmitter(t *testing.T) {
testOs := &fatalOs{t}
w := events.Default.Subscribe(events.DownloadProgress)
c := createTmpWrapper(config.Configuration{})
defer os.Remove(c.ConfigPath())
defer testOs.Remove(c.ConfigPath())
c.SetOptions(config.OptionsConfiguration{
ProgressUpdateIntervalS: 0,
})
@@ -103,8 +104,10 @@ func TestProgressEmitter(t *testing.T) {
}
func TestSendDownloadProgressMessages(t *testing.T) {
testOs := &fatalOs{t}
c := createTmpWrapper(config.Configuration{})
defer os.Remove(c.ConfigPath())
defer testOs.Remove(c.ConfigPath())
c.SetOptions(config.OptionsConfiguration{
ProgressUpdateIntervalS: 0,
TempIndexMinBlocks: 10,