all: Grand test refactor (fixes #8779, fixes #8799)

This fixes various test issues with Go 1.20.

- Most tests rewritten to use fakefs where possible
- Some tests that were already skipped, or dubious (invasive,
  unmaintainable, unclear what they even tested) have been removed
- Some actual code rewritten to better support testing in fakefs

Co-authored-by: Eric P <eric@kastelo.net>
This commit is contained in:
Jakob Borg
2023-05-09 10:01:57 +00:00
co-authored by Eric P
parent ddce692f72
commit 1103a27337
54 changed files with 1133 additions and 1594 deletions
+4 -5
View File
@@ -60,7 +60,7 @@ func TestProgressEmitter(t *testing.T) {
w := evLogger.Subscribe(events.DownloadProgress)
c, cfgCancel := createTmpWrapper(config.Configuration{})
c, cfgCancel := newConfigWrapper(config.Configuration{Version: config.CurrentVersion})
defer os.Remove(c.ConfigPath())
defer cfgCancel()
waiter, err := c.Modify(func(cfg *config.Configuration) {
@@ -110,11 +110,10 @@ func TestProgressEmitter(t *testing.T) {
expectEvent(w, t, 0)
expectTimeout(w, t)
}
func TestSendDownloadProgressMessages(t *testing.T) {
c, cfgCancel := createTmpWrapper(config.Configuration{})
c, cfgCancel := newConfigWrapper(config.Configuration{Version: config.CurrentVersion})
defer os.Remove(c.ConfigPath())
defer cfgCancel()
waiter, err := c.Modify(func(cfg *config.Configuration) {
@@ -455,8 +454,8 @@ func TestSendDownloadProgressMessages(t *testing.T) {
// See progressemitter.go for explanation why this is commented out.
// Search for state.cleanup
//expect(-1, state2, protocol.FileDownloadProgressUpdateTypeForget, v1, nil, false)
//expect(-1, state4, protocol.FileDownloadProgressUpdateTypeForget, v1, nil, true)
// expect(-1, state2, protocol.FileDownloadProgressUpdateTypeForget, v1, nil, false)
// expect(-1, state4, protocol.FileDownloadProgressUpdateTypeForget, v1, nil, true)
expectEmpty()