Skip to content

Commit

Permalink
Merge branch 'main' into timeout-duration
Browse files Browse the repository at this point in the history
  • Loading branch information
ackleymi authored Oct 27, 2023
2 parents a5e1a4d + 2feb378 commit 046163e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
4 changes: 4 additions & 0 deletions datadictionary/datadictionary.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,10 @@ func Parse(path string) (*DataDictionary, error) {
func ParseSrc(xmlSrc io.Reader) (*DataDictionary, error) {
doc := new(XMLDoc)
decoder := xml.NewDecoder(xmlSrc)
decoder.CharsetReader = func(encoding string, input io.Reader) (io.Reader, error) {
return input, nil
}

if err := decoder.Decode(doc); err != nil {
return nil, errors.Wrapf(err, "problem parsing XML file")
}
Expand Down
5 changes: 3 additions & 2 deletions filestore.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"os"
"path"
"strconv"
"strings"
"time"

"github.com/pkg/errors"
Expand Down Expand Up @@ -213,15 +214,15 @@ func (store *fileStore) populateCache() (creationTimePopulated bool, err error)
}

if senderSeqNumBytes, err := ioutil.ReadFile(store.senderSeqNumsFname); err == nil {
if senderSeqNum, err := strconv.Atoi(string(senderSeqNumBytes)); err == nil {
if senderSeqNum, err := strconv.Atoi(strings.Trim(string(senderSeqNumBytes), "\r\n")); err == nil {
if err = store.cache.SetNextSenderMsgSeqNum(senderSeqNum); err != nil {
return creationTimePopulated, errors.Wrap(err, "cache set next sender")
}
}
}

if targetSeqNumBytes, err := ioutil.ReadFile(store.targetSeqNumsFname); err == nil {
if targetSeqNum, err := strconv.Atoi(string(targetSeqNumBytes)); err == nil {
if targetSeqNum, err := strconv.Atoi(strings.Trim(string(targetSeqNumBytes), "\r\n")); err == nil {
if err = store.cache.SetNextTargetMsgSeqNum(targetSeqNum); err != nil {
return creationTimePopulated, errors.Wrap(err, "cache set next target")
}
Expand Down
13 changes: 13 additions & 0 deletions filestore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ import (
"fmt"
"os"
"path"
"strconv"
"strings"
"testing"
"time"

assert2 "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
)
Expand Down Expand Up @@ -62,3 +64,14 @@ func (suite *FileStoreTestSuite) TearDownTest() {
func TestFileStoreTestSuite(t *testing.T) {
suite.Run(t, new(FileStoreTestSuite))
}

func TestStringParse(t *testing.T) {
assert := assert2.New(t)
i, err := strconv.Atoi(strings.Trim("00005\n", "\r\n"))
assert.Nil(err)
assert.Equal(5, i)

i, err = strconv.Atoi(strings.Trim("00006\r", "\r\n"))
assert.Nil(err)
assert.Equal(6, i)
}
1 change: 1 addition & 0 deletions validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ func validateVisitGroupField(fieldDef *datadictionary.FieldDef, fieldStack []Tag
if childDefs[0].Required() {
return fieldStack, RequiredTagMissing(Tag(childDefs[0].Tag()))
}
fieldStack = fieldStack[1:]
}

childDefs = childDefs[1:]
Expand Down

0 comments on commit 046163e

Please sign in to comment.