Skip to content

Commit

Permalink
Fixed error 'error importing field: ... unknown prefix: None.Fixed fo…
Browse files Browse the repository at this point in the history
…r field: ...', related test added (#312)
  • Loading branch information
Fr0gN authored Jul 4, 2024
1 parent 0e5c8d4 commit 8523963
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions specs/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ var (
}

PrefixesExtToInt = map[string]prefix.Prefixer{
"None.Fixed": prefix.None.Fixed,
"ASCII.Fixed": prefix.ASCII.Fixed,
"ASCII.L": prefix.ASCII.L,
"ASCII.LL": prefix.ASCII.LL,
Expand Down
29 changes: 29 additions & 0 deletions specs/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,3 +248,32 @@ func TestSpecWithCompositeBitmapedFields(t *testing.T) {
require.NoError(t, err)
require.Equal(t, "22004000000000000011 456", string(packed))
}

func TestExportImportWithNonePrefixField(t *testing.T) {
spec := &iso8583.MessageSpec{
Fields: map[int]field.Field{
3: field.NewComposite(&field.Spec{
Description: "Processing code",
Pref: prefix.None.Fixed,
Tag: &field.TagSpec{
Enc: encoding.ASCII,
Sort: sort.StringsByInt,
},
Subfields: map[string]field.Field{
"1": field.NewNumeric(&field.Spec{
Length: 3,
Description: "Transaction code",
Enc: encoding.ASCII,
Pref: prefix.ASCII.Fixed,
}),
},
}),
},
}

specJSON, err := Builder.ExportJSON(spec)
require.NoError(t, err)

spec, err = Builder.ImportJSON(specJSON)
require.NoError(t, err)
}

0 comments on commit 8523963

Please sign in to comment.