Compare commits
No commits in common. "e754773bce9488b7fd33feb91f4b2b4fc1ff8392" and "a1056cf2877a90e16f79b7747be9d4e01f566bb4" have entirely different histories.
e754773bce
...
a1056cf287
@ -96,7 +96,13 @@ func main() {
|
|||||||
en = en.WithDebug(nil)
|
en = en.WithDebug(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = engine.Loop(ctx, en, os.Stdin, os.Stdout, nil)
|
_, err = en.Exec(ctx, []byte{})
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, "engine init exited with error: %v\n", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = engine.Loop(ctx, en, os.Stdin, os.Stdout)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "loop exited with error: %v\n", err)
|
fmt.Fprintf(os.Stderr, "loop exited with error: %v\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
2
go.mod
2
go.mod
@ -3,7 +3,7 @@ module git.grassecon.net/urdt/ussd
|
|||||||
go 1.22.6
|
go 1.22.6
|
||||||
|
|
||||||
require (
|
require (
|
||||||
git.defalsify.org/vise.git v0.1.0-rc.3.0.20240920144308-b2d2c5f18f38
|
git.defalsify.org/vise.git v0.1.0-rc.3.0.20240914163514-577f56f43bea
|
||||||
github.com/alecthomas/assert/v2 v2.2.2
|
github.com/alecthomas/assert/v2 v2.2.2
|
||||||
github.com/peteole/testdata-loader v0.3.0
|
github.com/peteole/testdata-loader v0.3.0
|
||||||
gopkg.in/leonelquinteros/gotext.v1 v1.3.1
|
gopkg.in/leonelquinteros/gotext.v1 v1.3.1
|
||||||
|
2
go.sum
2
go.sum
@ -2,8 +2,6 @@ git.defalsify.org/vise.git v0.1.0-rc.3.0.20240911231817-0d23e0dbb57f h1:CuJvG3Ny
|
|||||||
git.defalsify.org/vise.git v0.1.0-rc.3.0.20240911231817-0d23e0dbb57f/go.mod h1:JDguWmcoWBdsnpw7PUjVZAEpdC/ubBmjdUBy3tjP63M=
|
git.defalsify.org/vise.git v0.1.0-rc.3.0.20240911231817-0d23e0dbb57f/go.mod h1:JDguWmcoWBdsnpw7PUjVZAEpdC/ubBmjdUBy3tjP63M=
|
||||||
git.defalsify.org/vise.git v0.1.0-rc.3.0.20240914163514-577f56f43bea h1:6ZYT+dIjd/f5vn9y5AJDZ7SQQckA6w5ZfUoKygyI11o=
|
git.defalsify.org/vise.git v0.1.0-rc.3.0.20240914163514-577f56f43bea h1:6ZYT+dIjd/f5vn9y5AJDZ7SQQckA6w5ZfUoKygyI11o=
|
||||||
git.defalsify.org/vise.git v0.1.0-rc.3.0.20240914163514-577f56f43bea/go.mod h1:JDguWmcoWBdsnpw7PUjVZAEpdC/ubBmjdUBy3tjP63M=
|
git.defalsify.org/vise.git v0.1.0-rc.3.0.20240914163514-577f56f43bea/go.mod h1:JDguWmcoWBdsnpw7PUjVZAEpdC/ubBmjdUBy3tjP63M=
|
||||||
git.defalsify.org/vise.git v0.1.0-rc.3.0.20240920144308-b2d2c5f18f38 h1:4aAZijIcq33ixnZ+U48ckDIkwSfZL3St/CqoXZcC5K8=
|
|
||||||
git.defalsify.org/vise.git v0.1.0-rc.3.0.20240920144308-b2d2c5f18f38/go.mod h1:JDguWmcoWBdsnpw7PUjVZAEpdC/ubBmjdUBy3tjP63M=
|
|
||||||
github.com/alecthomas/assert/v2 v2.2.2 h1:Z/iVC0xZfWTaFNE6bA3z07T86hd45Xe2eLt6WVy2bbk=
|
github.com/alecthomas/assert/v2 v2.2.2 h1:Z/iVC0xZfWTaFNE6bA3z07T86hd45Xe2eLt6WVy2bbk=
|
||||||
github.com/alecthomas/assert/v2 v2.2.2/go.mod h1:pXcQ2Asjp247dahGEmsZ6ru0UVwnkhktn7S0bBDLxvQ=
|
github.com/alecthomas/assert/v2 v2.2.2/go.mod h1:pXcQ2Asjp247dahGEmsZ6ru0UVwnkhktn7S0bBDLxvQ=
|
||||||
github.com/alecthomas/participle/v2 v2.0.0 h1:Fgrq+MbuSsJwIkw3fEj9h75vDP0Er5JzepJ0/HNHv0g=
|
github.com/alecthomas/participle/v2 v2.0.0 h1:Fgrq+MbuSsJwIkw3fEj9h75vDP0Er5JzepJ0/HNHv0g=
|
||||||
|
@ -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.Flush(rqs.Ctx, rqs.Writer)
|
_, err = rqs.Engine.WriteResult(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.Flush(rqs.Ctx, rqs.Writer)
|
_, err = rqs.Engine.WriteResult(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.FlushFunc = func(context.Context, io.Writer) (int, error) { return 0, nil }
|
me.WriteResultFunc = 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{
|
||||||
FlushFunc: func(context.Context, io.Writer) (int, error) {
|
WriteResultFunc: 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{
|
||||||
FlushFunc: func(context.Context, io.Writer) (int, error) {
|
WriteResultFunc: 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: "Flush error",
|
name: "WriteResult error",
|
||||||
input: handlers.RequestSession{
|
input: handlers.RequestSession{
|
||||||
Continue: true,
|
Continue: true,
|
||||||
Engine: &httpmocks.MockEngine{
|
Engine: &httpmocks.MockEngine{
|
||||||
FlushFunc: func(context.Context, io.Writer) (int, error) {
|
WriteResultFunc: func(context.Context, io.Writer) (int, error) {
|
||||||
return 0, errors.New("write error")
|
return 0, errors.New("write error")
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -7,10 +7,10 @@ import (
|
|||||||
|
|
||||||
// MockEngine implements the engine.Engine interface for testing
|
// MockEngine implements the engine.Engine interface for testing
|
||||||
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)
|
||||||
FlushFunc func(context.Context, io.Writer) (int, error)
|
WriteResultFunc func(context.Context, io.Writer) (int, error)
|
||||||
FinishFunc func() error
|
FinishFunc func() error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MockEngine) Init(ctx context.Context) (bool, error) {
|
func (m *MockEngine) Init(ctx context.Context) (bool, 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) Flush(ctx context.Context, w io.Writer) (int, error) {
|
func (m *MockEngine) WriteResult(ctx context.Context, w io.Writer) (int, error) {
|
||||||
return m.FlushFunc(ctx, w)
|
return m.WriteResultFunc(ctx, w)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MockEngine) Finish() error {
|
func (m *MockEngine) Finish() error {
|
||||||
|
Loading…
Reference in New Issue
Block a user