22 lines
344 B
Go
22 lines
344 B
Go
package test
|
|
|
|
import "errors"
|
|
|
|
var errRepositoryFailure = errors.New("repository failure")
|
|
|
|
type failSwitch struct {
|
|
method string
|
|
}
|
|
|
|
func (f *failSwitch) failNext(method string) {
|
|
f.method = method
|
|
}
|
|
|
|
func (f *failSwitch) trigger(method string) error {
|
|
if f.method == method {
|
|
f.method = ""
|
|
return errRepositoryFailure
|
|
}
|
|
return nil
|
|
}
|