@@ -28,7 +28,7 @@ func mockCashLetterControl() *CashLetterControl {
28
28
// TestMockCashLetterControl creates a CashLetterControl
29
29
func TestMockCashLetterControl (t * testing.T ) {
30
30
clc := mockCashLetterControl ()
31
- require .NoError (t , clc .Validate ("01" ))
31
+ require .NoError (t , clc .Validate ())
32
32
require .Equal (t , "90" , clc .recordType )
33
33
require .Equal (t , 1 , clc .CashLetterBundleCount )
34
34
require .Equal (t , 7 , clc .CashLetterItemsCount )
@@ -45,7 +45,7 @@ func TestParseCashLetterControl(t *testing.T) {
45
45
r .line = line
46
46
clh := mockCashLetterHeader ()
47
47
r .addCurrentCashLetter (NewCashLetter (clh ))
48
- require .NoError (t , r .parseCashLetterControl ("03" ))
48
+ require .NoError (t , r .parseCashLetterControl ())
49
49
record := r .currentCashLetter .CashLetterControl
50
50
51
51
require .Equal (t , "90" , record .recordType )
@@ -66,7 +66,7 @@ func testCLCString(t testing.TB) {
66
66
r .line = line
67
67
clh := mockCashLetterHeader ()
68
68
r .addCurrentCashLetter (NewCashLetter (clh ))
69
- require .NoError (t , r .parseCashLetterControl ("01" ))
69
+ require .NoError (t , r .parseCashLetterControl ())
70
70
record := r .currentCashLetter .CashLetterControl
71
71
require .Equal (t , line , record .String ())
72
72
}
@@ -88,7 +88,7 @@ func BenchmarkCLCString(b *testing.B) {
88
88
func TestCLCRecordType (t * testing.T ) {
89
89
clc := mockCashLetterControl ()
90
90
clc .recordType = "00"
91
- err := clc .Validate ("01" )
91
+ err := clc .Validate ()
92
92
var fieldErr * FieldError
93
93
require .ErrorAs (t , err , & fieldErr )
94
94
require .Equal (t , "recordType" , fieldErr .FieldName )
@@ -98,7 +98,7 @@ func TestCLCRecordType(t *testing.T) {
98
98
func TestECEInstitutionName (t * testing.T ) {
99
99
clc := mockCashLetterControl ()
100
100
clc .ECEInstitutionName = "®©"
101
- err := clc .Validate ("01" )
101
+ err := clc .Validate ()
102
102
var fieldErr * FieldError
103
103
require .ErrorAs (t , err , & fieldErr )
104
104
require .Equal (t , "ECEInstitutionName" , fieldErr .FieldName )
@@ -108,7 +108,7 @@ func TestECEInstitutionName(t *testing.T) {
108
108
func TestCLCCreditTotalIndicator (t * testing.T ) {
109
109
clc := mockCashLetterControl ()
110
110
clc .CreditTotalIndicator = 9
111
- err := clc .Validate ("01" )
111
+ err := clc .Validate ()
112
112
var fieldErr * FieldError
113
113
require .ErrorAs (t , err , & fieldErr )
114
114
require .Equal (t , "CreditTotalIndicator" , fieldErr .FieldName )
@@ -118,7 +118,7 @@ func TestCLCCreditTotalIndicator(t *testing.T) {
118
118
func TestCLCFieldInclusionRecordType (t * testing.T ) {
119
119
clc := mockCashLetterControl ()
120
120
clc .recordType = ""
121
- err := clc .Validate ("01" )
121
+ err := clc .Validate ()
122
122
var fieldErr * FieldError
123
123
require .ErrorAs (t , err , & fieldErr )
124
124
require .Equal (t , "recordType" , fieldErr .FieldName )
@@ -128,7 +128,7 @@ func TestCLCFieldInclusionRecordType(t *testing.T) {
128
128
func TestFieldInclusionCashLetterItemsCount (t * testing.T ) {
129
129
clc := mockCashLetterControl ()
130
130
clc .CashLetterItemsCount = 0
131
- err := clc .Validate ("01" )
131
+ err := clc .Validate ()
132
132
var fieldErr * FieldError
133
133
require .ErrorAs (t , err , & fieldErr )
134
134
require .Equal (t , "CashLetterItemsCount" , fieldErr .FieldName )
@@ -138,7 +138,7 @@ func TestFieldInclusionCashLetterItemsCount(t *testing.T) {
138
138
func TestFieldInclusionCashLetterTotalAmount (t * testing.T ) {
139
139
clc := mockCashLetterControl ()
140
140
clc .CashLetterTotalAmount = 0
141
- err := clc .Validate ("01" )
141
+ err := clc .Validate ()
142
142
var fieldErr * FieldError
143
143
require .ErrorAs (t , err , & fieldErr )
144
144
require .Equal (t , "CashLetterTotalAmount" , fieldErr .FieldName )
@@ -147,8 +147,9 @@ func TestFieldInclusionCashLetterTotalAmount(t *testing.T) {
147
147
// TestFieldInclusionSettlementDate validates FieldInclusion
148
148
func TestFieldInclusionRecordTypeSettlementDate (t * testing.T ) {
149
149
clc := mockCashLetterControl ()
150
- clc .SettlementDate = time.Time {}
151
- err := clc .Validate ("01" )
150
+ // if present (non-zero), SettlementDate.Year() must be between 1993 and 9999
151
+ clc .SettlementDate = time .Date (40010 , time .November , 9 , 0 , 0 , 0 , 0 , time .UTC )
152
+ err := clc .Validate ()
152
153
var fieldErr * FieldError
153
154
require .ErrorAs (t , err , & fieldErr )
154
155
require .Equal (t , "SettlementDate" , fieldErr .FieldName )
@@ -162,3 +163,24 @@ func TestCashLetterControlRuneCountInString(t *testing.T) {
162
163
163
164
require .Equal (t , 0 , clc .CashLetterBundleCount )
164
165
}
166
+
167
+ func TestCashLetterControl_isReturnCollectionType (t * testing.T ) {
168
+ tests := []struct {
169
+ collectionType string
170
+ expected bool
171
+ }{
172
+ {"03" , true },
173
+ {"04" , true },
174
+ {"05" , true },
175
+ {"06" , true },
176
+ {"07" , false },
177
+ {"01" , false },
178
+ {"" , false },
179
+ }
180
+
181
+ for _ , tt := range tests {
182
+ t .Run (tt .collectionType , func (t * testing.T ) {
183
+ require .Equal (t , tt .expected , isReturnCollectionType (tt .collectionType ))
184
+ })
185
+ }
186
+ }
0 commit comments