rename all WriteResult to Flush
This commit is contained in:
parent
a7e38727f1
commit
3a14dafb98
@ -87,7 +87,7 @@ func(f *BaseSessionHandler) Process(rqs RequestSession) (RequestSession, error)
|
|||||||
|
|
||||||
func(f *BaseSessionHandler) Output(rqs RequestSession) (RequestSession, error) {
|
func(f *BaseSessionHandler) Output(rqs RequestSession) (RequestSession, error) {
|
||||||
var err error
|
var err error
|
||||||
_, err = rqs.Engine.WriteResult(rqs.Ctx, rqs.Writer)
|
_, err = rqs.Engine.Flush(rqs.Ctx, rqs.Writer)
|
||||||
return rqs, err
|
return rqs, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,6 +87,6 @@ func (ash *ATSessionHandler) Output(rqs handlers.RequestSession) (handlers.Reque
|
|||||||
return rqs, err
|
return rqs, err
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = rqs.Engine.WriteResult(rqs.Ctx, rqs.Writer)
|
_, err = rqs.Engine.Flush(rqs.Ctx, rqs.Writer)
|
||||||
return rqs, err
|
return rqs, err
|
||||||
}
|
}
|
@ -69,7 +69,7 @@ func TestATSessionHandler_ServeHTTP(t *testing.T) {
|
|||||||
mh.GetRequestParserFunc = func() handlers.RequestParser { return mrp }
|
mh.GetRequestParserFunc = func() handlers.RequestParser { return mrp }
|
||||||
mh.OutputFunc = func(rs handlers.RequestSession) (handlers.RequestSession, error) { return rs, nil }
|
mh.OutputFunc = func(rs handlers.RequestSession) (handlers.RequestSession, error) { return rs, nil }
|
||||||
mh.ResetFunc = func(rs handlers.RequestSession) (handlers.RequestSession, error) { return rs, nil }
|
mh.ResetFunc = func(rs handlers.RequestSession) (handlers.RequestSession, error) { return rs, nil }
|
||||||
me.WriteResultFunc = func(context.Context, io.Writer) (int, error) { return 0, nil }
|
me.FlushFunc = func(context.Context, io.Writer) (int, error) { return 0, nil }
|
||||||
},
|
},
|
||||||
formData: url.Values{
|
formData: url.Values{
|
||||||
"phoneNumber": []string{"+1234567890"},
|
"phoneNumber": []string{"+1234567890"},
|
||||||
@ -178,7 +178,7 @@ func TestATSessionHandler_Output(t *testing.T) {
|
|||||||
input: handlers.RequestSession{
|
input: handlers.RequestSession{
|
||||||
Continue: true,
|
Continue: true,
|
||||||
Engine: &httpmocks.MockEngine{
|
Engine: &httpmocks.MockEngine{
|
||||||
WriteResultFunc: func(context.Context, io.Writer) (int, error) {
|
FlushFunc: func(context.Context, io.Writer) (int, error) {
|
||||||
return 0, nil
|
return 0, nil
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -192,7 +192,7 @@ func TestATSessionHandler_Output(t *testing.T) {
|
|||||||
input: handlers.RequestSession{
|
input: handlers.RequestSession{
|
||||||
Continue: false,
|
Continue: false,
|
||||||
Engine: &httpmocks.MockEngine{
|
Engine: &httpmocks.MockEngine{
|
||||||
WriteResultFunc: func(context.Context, io.Writer) (int, error) {
|
FlushFunc: func(context.Context, io.Writer) (int, error) {
|
||||||
return 0, nil
|
return 0, nil
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -202,11 +202,11 @@ func TestATSessionHandler_Output(t *testing.T) {
|
|||||||
expectedError: false,
|
expectedError: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "WriteResult error",
|
name: "Flush error",
|
||||||
input: handlers.RequestSession{
|
input: handlers.RequestSession{
|
||||||
Continue: true,
|
Continue: true,
|
||||||
Engine: &httpmocks.MockEngine{
|
Engine: &httpmocks.MockEngine{
|
||||||
WriteResultFunc: func(context.Context, io.Writer) (int, error) {
|
FlushFunc: func(context.Context, io.Writer) (int, error) {
|
||||||
return 0, errors.New("write error")
|
return 0, errors.New("write error")
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
type MockEngine struct {
|
type MockEngine struct {
|
||||||
InitFunc func(context.Context) (bool, error)
|
InitFunc func(context.Context) (bool, error)
|
||||||
ExecFunc func(context.Context, []byte) (bool, error)
|
ExecFunc func(context.Context, []byte) (bool, error)
|
||||||
WriteResultFunc func(context.Context, io.Writer) (int, error)
|
FlushFunc func(context.Context, io.Writer) (int, error)
|
||||||
FinishFunc func() error
|
FinishFunc func() error
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -21,8 +21,8 @@ func (m *MockEngine) Exec(ctx context.Context, input []byte) (bool, error) {
|
|||||||
return m.ExecFunc(ctx, input)
|
return m.ExecFunc(ctx, input)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MockEngine) WriteResult(ctx context.Context, w io.Writer) (int, error) {
|
func (m *MockEngine) Flush(ctx context.Context, w io.Writer) (int, error) {
|
||||||
return m.WriteResultFunc(ctx, w)
|
return m.FlushFunc(ctx, w)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MockEngine) Finish() error {
|
func (m *MockEngine) Finish() error {
|
||||||
|
Loading…
Reference in New Issue
Block a user