From 05f665ffc61861498ebad6b330831a1ded879374 Mon Sep 17 00:00:00 2001 From: Pavel Gabriel Date: Wed, 17 Jul 2024 11:00:23 +0200 Subject: [PATCH] update iso8583 version (#83) --- connection.go | 5 +++-- connection_test.go | 5 +++-- go.mod | 4 ++-- go.sum | 4 ++++ server/server_test.go | 10 +++++----- 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/connection.go b/connection.go index c08c121..82c56ea 100644 --- a/connection.go +++ b/connection.go @@ -12,6 +12,7 @@ import ( "time" "github.com/moov-io/iso8583" + iso8583Errors "github.com/moov-io/iso8583/errors" "github.com/moov-io/iso8583/utils" ) @@ -580,7 +581,7 @@ func (c *Connection) writeLoop() { if err != nil { c.handleError(fmt.Errorf("writing message: %w", err)) - var packErr *iso8583.PackError + var packErr *iso8583Errors.PackError if errors.As(err, &packErr) { // let caller know that the message was not sent because of pack error. // We don't set all type of errors to errCh as this case is handled @@ -646,7 +647,7 @@ func (c *Connection) readLoop() { // if err is UnpackError, we can still continue reading // from the connection - var unpackErr *iso8583.UnpackError + var unpackErr *iso8583Errors.UnpackError if errors.As(err, &unpackErr) { continue } diff --git a/connection_test.go b/connection_test.go index df78981..115e57d 100644 --- a/connection_test.go +++ b/connection_test.go @@ -17,6 +17,7 @@ import ( "github.com/moov-io/iso8583" connection "github.com/moov-io/iso8583-connection" "github.com/moov-io/iso8583/encoding" + iso8583Errors "github.com/moov-io/iso8583/errors" "github.com/moov-io/iso8583/field" "github.com/moov-io/iso8583/prefix" "github.com/stretchr/testify/require" @@ -390,7 +391,7 @@ func TestClient_Send(t *testing.T) { // then Send should return PackError require.Error(t, err) - var packError *iso8583.PackError + var packError *iso8583Errors.PackError require.ErrorAs(t, err, &packError) }) @@ -468,7 +469,7 @@ func TestClient_Send(t *testing.T) { mu.Lock() defer mu.Unlock() - var unpackErr *iso8583.UnpackError + var unpackErr *iso8583Errors.UnpackError if errors.As(handledError, &unpackErr) { require.EqualError(t, handledError, "failed to read message from connection") require.EqualError(t, unpackErr, "failed to unpack field 63: no specification found") diff --git a/go.mod b/go.mod index 53aa007..d20e502 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/moov-io/iso8583-connection go 1.21 require ( - github.com/moov-io/iso8583 v0.21.2 + github.com/moov-io/iso8583 v0.22.0 github.com/stretchr/testify v1.9.0 ) @@ -12,6 +12,6 @@ require ( github.com/kr/text v0.2.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/yerden/go-util v1.1.4 // indirect - golang.org/x/text v0.14.0 // indirect + golang.org/x/text v0.16.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index b151b9a..cda106d 100644 --- a/go.sum +++ b/go.sum @@ -18,6 +18,8 @@ github.com/moov-io/iso8583 v0.21.1 h1:2SnBom/yw2XJSPP4tUZVgKsNfICz5BKubd8Q33JRsH github.com/moov-io/iso8583 v0.21.1/go.mod h1:vvlp3liWXnH5pI9dl5PvrtpjS7ZxcdxyYWvd4FpI66A= github.com/moov-io/iso8583 v0.21.2 h1:FHHbFXFOfEK9yA8siupnmUei77ZNB/74o4NsANu9me8= github.com/moov-io/iso8583 v0.21.2/go.mod h1:DePfPe8TCTrSUETPpMq1LQdfSuFj4qxZPkYyb9/cS7I= +github.com/moov-io/iso8583 v0.22.0 h1:iFniftFGVfRtEHU2EtTQ2KzwNYlZrN6wiQmfwMwFPZE= +github.com/moov-io/iso8583 v0.22.0/go.mod h1:seEv9uPMu6ESrBFLpMLXb4wpXg2iEeF4PIOzqpetbOA= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= @@ -31,6 +33,8 @@ golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= +golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/server/server_test.go b/server/server_test.go index df632c6..dbcf8dc 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -6,11 +6,10 @@ import ( "io" "net" "sync" + "sync/atomic" "testing" "time" - "sync/atomic" - "github.com/moov-io/iso8583" connection "github.com/moov-io/iso8583-connection" "github.com/moov-io/iso8583-connection/server" @@ -66,7 +65,7 @@ func TestServer_WithConnectionFactory(t *testing.T) { defer s.Close() var isCalled atomic.Bool - var expectedErr = fmt.Errorf("error from connection factory") + expectedErr := fmt.Errorf("error from connection factory") var gotErr error var mu sync.Mutex @@ -95,7 +94,9 @@ func TestServer_WithConnectionFactory(t *testing.T) { err = conn.Connect() require.NoError(t, err) - conn.Close() + err = conn.Close() + require.NoError(t, err) + s.Close() require.Eventually(t, func() bool { @@ -104,7 +105,6 @@ func TestServer_WithConnectionFactory(t *testing.T) { require.ErrorIs(t, gotErr, expectedErr) }) - } type lengthHeader struct {