-
Notifications
You must be signed in to change notification settings - Fork 39
/
cashLetter_test.go
64 lines (56 loc) · 1.99 KB
/
cashLetter_test.go
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
55
56
57
58
59
60
61
62
63
64
package imagecashletter
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestCashLetterPanics(t *testing.T) {
var cl *CashLetter
require.Nil(t, cl.GetBundles())
require.Nil(t, cl.GetRoutingNumberSummary())
require.Nil(t, cl.GetCreditItems())
}
// TestCashLetterNoBundle validates no Bundle when CashLetterHeader.RecordTypeIndicator = "N"
func TestCashLetterNoBundle(t *testing.T) {
// Create CheckDetail
cd := mockCheckDetail()
cd.AddCheckDetailAddendumA(mockCheckDetailAddendumA())
cd.AddCheckDetailAddendumB(mockCheckDetailAddendumB())
cd.AddCheckDetailAddendumC(mockCheckDetailAddendumC())
cd.AddImageViewDetail(mockImageViewDetail())
cd.AddImageViewData(mockImageViewData())
cd.AddImageViewAnalysis(mockImageViewAnalysis())
bundle := NewBundle(mockBundleHeader())
bundle.AddCheckDetail(cd)
// Create CashLetter
cl := NewCashLetter(mockCashLetterHeader())
cl.GetHeader().RecordTypeIndicator = "N"
cl.AddBundle(bundle)
err := cl.Create()
var e *CashLetterError
require.ErrorAs(t, err, &e)
require.Equal(t, "RecordTypeIndicator", e.FieldName)
}
// TestCashLetterNoRoutingNumberSummary validates no Bundle when CashLetterHeader.CollectionTypeIndicator is not
// 00, 01, 02
func TestCashLetterRoutingNumberSummary(t *testing.T) {
// Create CheckDetail
cd := mockCheckDetail()
cd.AddCheckDetailAddendumA(mockCheckDetailAddendumA())
cd.AddCheckDetailAddendumB(mockCheckDetailAddendumB())
cd.AddCheckDetailAddendumC(mockCheckDetailAddendumC())
cd.AddImageViewDetail(mockImageViewDetail())
cd.AddImageViewData(mockImageViewData())
cd.AddImageViewAnalysis(mockImageViewAnalysis())
bundle := NewBundle(mockBundleHeader())
bundle.AddCheckDetail(cd)
// Create CashLetter
cl := NewCashLetter(mockCashLetterHeader())
cl.GetHeader().CollectionTypeIndicator = "03"
cl.AddBundle(bundle)
rns := mockRoutingNumberSummary()
cl.AddRoutingNumberSummary(rns)
err := cl.Create()
var e *CashLetterError
require.ErrorAs(t, err, &e)
require.Equal(t, "CollectionTypeIndicator", e.FieldName)
}