lib/model, lib/testutils: Test closing a connection on folder restart (#5707)

This commit is contained in:
Simon Frei
2019-05-18 08:53:59 +02:00
committed by Jakob Borg
parent 5ffbb7668d
commit 1b2b970f32
3 changed files with 106 additions and 24 deletions

View File

@@ -0,0 +1,31 @@
// Copyright (C) 2019 The Syncthing Authors.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at https://mozilla.org/MPL/2.0/.
package testutils
// BlockingRW implements io.Reader and Writer but never returns when called
type BlockingRW struct{ nilChan chan struct{} }
func (rw *BlockingRW) Read(p []byte) (n int, err error) {
<-rw.nilChan
return
}
func (rw *BlockingRW) Write(p []byte) (n int, err error) {
<-rw.nilChan
return
}
// NoopRW implements io.Reader and Writer but never returns when called
type NoopRW struct{}
func (rw *NoopRW) Read(p []byte) (n int, err error) {
return len(p), nil
}
func (rw *NoopRW) Write(p []byte) (n int, err error) {
return len(p), nil
}