package test import "errors" var errRepositoryFailure = errors.New("repository failure") type failSwitch struct { method string err error } func (f *failSwitch) failNext(method string) { f.method = method f.err = nil } func (f *failSwitch) failNextWith(method string, err error) { f.method = method f.err = err } func (f *failSwitch) trigger(method string) error { if f.method == method { f.method = "" if f.err != nil { err := f.err f.err = nil return err } return errRepositoryFailure } return nil } const migrationPublicURL = "https://www.example.com"