From 85239638962d142d63a6397a3d9b3e3c79800d15 Mon Sep 17 00:00:00 2001 From: Fr0gN <58360017+Fr0gN@users.noreply.github.com> Date: Thu, 4 Jul 2024 12:30:57 +0500 Subject: [PATCH] Fixed error 'error importing field: ... unknown prefix: None.Fixed for field: ...', related test added (#312) --- specs/builder.go | 1 + specs/builder_test.go | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/specs/builder.go b/specs/builder.go index 32f656f1..259df806 100644 --- a/specs/builder.go +++ b/specs/builder.go @@ -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, diff --git a/specs/builder_test.go b/specs/builder_test.go index 8af45145..87a689f9 100644 --- a/specs/builder_test.go +++ b/specs/builder_test.go @@ -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) +}