diff --git a/internal/test/download_test.go b/internal/test/download_test.go index 5ccd525..a00cbb4 100644 --- a/internal/test/download_test.go +++ b/internal/test/download_test.go @@ -25,6 +25,7 @@ import ( "net/http" "os" "path/filepath" + "sort" "strings" "testing" "time" @@ -164,6 +165,10 @@ func TestODFIDownload(t *testing.T) { require.NoError(t, err) err = os.WriteFile(emptyFilepath, buf.Bytes(), info.Mode()) require.NoError(t, err) + info, err = os.Stat(filepath.Join(filepath.Dir(emptyFilepath), "ppd-debit-bad.ach")) + require.NoError(t, err) + err = os.WriteFile(emptyFilepath, buf.Bytes(), info.Mode()) + require.NoError(t, err) // Fix permissions to allow deleting files on CI if os.Getenv("GITHUB_ACTIONS") != "" { err = os.Chmod(filepath.Dir(emptyFilepath), 0777) @@ -232,11 +237,14 @@ func TestODFIDownload(t *testing.T) { } // Verify Reconciliations - assert.Len(t, reconciliations, 1) - if len(reconciliations) > 0 { - assert.Equal(t, "ppd-debit.ach", reconciliations[0].Filename) - assert.Len(t, reconciliations[0].Reconciliations, 1) - } + require.Len(t, reconciliations, 2) + sort.Slice(reconciliations, func(i, j int) bool { + return reconciliations[i].Filename < reconciliations[j].Filename + }) + assert.Equal(t, "ppd-debit-bad.ach", reconciliations[0].Filename) + require.Len(t, reconciliations[0].Reconciliations, 2) + assert.Equal(t, "ppd-debit.ach", reconciliations[1].Filename) + require.Len(t, reconciliations[1].Reconciliations, 1) // Verify Returns assert.Len(t, returns, 1) @@ -258,7 +266,7 @@ func TestODFIDownload(t *testing.T) { require.NoError(t, err) containsFilepaths(t, filenames, []string{ "/inbound/cor-c01.ach", "/inbound/iat-credit.ach", - "/reconciliation/empty.txt", "/reconciliation/ppd-debit.ach", + "/reconciliation/empty.txt", "/reconciliation/ppd-debit.ach", "/reconciliation/ppd-debit-bad.ach", "/returned/return-WEB.ach", }) @@ -279,6 +287,7 @@ func TestODFIDownload(t *testing.T) { fmt.Sprintf("/odfi/127.0.0.1:2222/inbound/%s/cor-c01.ach", yymmdd), fmt.Sprintf("/odfi/127.0.0.1:2222/inbound/%s/iat-credit.ach", yymmdd), fmt.Sprintf("/odfi/127.0.0.1:2222/reconciliation/%s/ppd-debit.ach", yymmdd), + fmt.Sprintf("/odfi/127.0.0.1:2222/reconciliation/%s/ppd-debit-bad.ach", yymmdd), fmt.Sprintf("/odfi/127.0.0.1:2222/returned/%s/return-WEB.ach", yymmdd), }) diff --git a/testdata/download-test/reconciliation/ppd-debit-bad.ach b/testdata/download-test/reconciliation/ppd-debit-bad.ach new file mode 100644 index 0000000..44c1c05 --- /dev/null +++ b/testdata/download-test/reconciliation/ppd-debit-bad.ach @@ -0,0 +1,7 @@ +5200Adam Shannon MOOVYYYYYYPPDtest trans2005262005271491273976360000188 +62627397636915XXXXXXXXXX1 0000000146ae1300b1c1cac5cVeridian Credit Union te1273976361273620 +82000000010027397636000000000146000000000000MOOVYYYYYY 273976360000188 +6212739763691XXXXXXXXXXX2 0000000008dcd5f1ce42ae2e1Adam Shannon ac1323274270765782 +6212739763691XXXXXXXXXXX2 0000000019908ac8a237911d6Adam Shannon ac1323274270765783 +6212739763691XXXXXXXXXXX2 0000000019908ac8a237911d6Adam Shannon ac1323274270765784 +82000000030082192908000000000000000000000046MOOVYYYYYY 323274270000085