-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patherrorWire_test.go
More file actions
54 lines (43 loc) · 1.4 KB
/
errorWire_test.go
File metadata and controls
54 lines (43 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package wire
import (
"strings"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
// mockErrorWire creates a ErrorWire
func mockErrorWire() *ErrorWire {
ew := NewErrorWire()
ew.ErrorCategory = "E"
ew.ErrorCode = "XYZ"
ew.ErrorDescription = "Data Error"
return ew
}
// TestMockErrorWire validates mockErrorWire
func TestMockErrorWire(t *testing.T) {
ew := mockErrorWire()
require.NoError(t, ew.Validate(), "mockErrorWire does not validate and will break other tests")
}
// TestParseErrorWire parses a known ErrorWire record string
func TestParseErrorWire(t *testing.T) {
var line = "{1130}1XYZINVLD CYCLE DT/MISSING/INVLD {1520}*"
r := NewReader(strings.NewReader(line))
r.line = line
require.NoError(t, r.parseErrorWire())
record := r.currentFEDWireMessage.ErrorWire
assert.Equal(t, "1", record.ErrorCategory)
assert.Equal(t, "XYZ", record.ErrorCode)
assert.Equal(t, "INVLD CYCLE DT/MISSING/INVLD {1520}", record.ErrorDescription)
assert.Equal(t, line, record.String())
}
func TestParseErrorWireEmptyDescription(t *testing.T) {
var line = "{1130}1XYZ*"
r := NewReader(strings.NewReader(line))
r.line = line
require.NoError(t, r.parseErrorWire())
record := r.currentFEDWireMessage.ErrorWire
assert.Equal(t, "1", record.ErrorCategory)
assert.Equal(t, "XYZ", record.ErrorCode)
assert.Equal(t, "", record.ErrorDescription)
assert.Equal(t, line, record.String())
}