visedriver/testutil/mocks/httpmocks/requesthandlermock.go

48 lines
1.5 KiB
Go
Raw Normal View History

2024-10-24 11:05:11 +02:00
package httpmocks
import (
"git.defalsify.org/vise.git/engine"
"git.defalsify.org/vise.git/persist"
"git.defalsify.org/vise.git/resource"
2025-01-04 23:27:46 +01:00
"git.grassecon.net/urdt/ussd/request"
2024-10-24 11:05:11 +02:00
)
2025-01-04 23:27:46 +01:00
// MockRequestHandler implements request.RequestHandler interface for testing
2024-10-24 11:05:11 +02:00
type MockRequestHandler struct {
2025-01-04 23:27:46 +01:00
ProcessFunc func(request.RequestSession) (request.RequestSession, error)
2024-10-24 11:05:11 +02:00
GetConfigFunc func() engine.Config
GetEngineFunc func(cfg engine.Config, rs resource.Resource, pe *persist.Persister) engine.Engine
2025-01-04 23:27:46 +01:00
OutputFunc func(rs request.RequestSession) (request.RequestSession, error)
ResetFunc func(rs request.RequestSession) (request.RequestSession, error)
2024-10-24 11:05:11 +02:00
ShutdownFunc func()
2025-01-04 23:27:46 +01:00
GetRequestParserFunc func() request.RequestParser
2024-10-24 11:05:11 +02:00
}
2025-01-04 23:27:46 +01:00
func (m *MockRequestHandler) Process(rqs request.RequestSession) (request.RequestSession, error) {
2024-10-24 11:05:11 +02:00
return m.ProcessFunc(rqs)
}
func (m *MockRequestHandler) GetConfig() engine.Config {
return m.GetConfigFunc()
}
func (m *MockRequestHandler) GetEngine(cfg engine.Config, rs resource.Resource, pe *persist.Persister) engine.Engine {
return m.GetEngineFunc(cfg, rs, pe)
}
2025-01-04 23:27:46 +01:00
func (m *MockRequestHandler) Output(rs request.RequestSession) (request.RequestSession, error) {
2024-10-24 11:05:11 +02:00
return m.OutputFunc(rs)
}
2025-01-04 23:27:46 +01:00
func (m *MockRequestHandler) Reset(rs request.RequestSession) (request.RequestSession, error) {
2024-10-24 11:05:11 +02:00
return m.ResetFunc(rs)
}
func (m *MockRequestHandler) Shutdown() {
m.ShutdownFunc()
}
2025-01-04 23:27:46 +01:00
func (m *MockRequestHandler) GetRequestParser() request.RequestParser {
2024-10-24 11:05:11 +02:00
return m.GetRequestParserFunc()
}