Skip to content
This repository was archived by the owner on Jun 4, 2026. It is now read-only.

Commit dfab449

Browse files
committed
test: improve code coverage
1 parent b99cfd5 commit dfab449

3 files changed

Lines changed: 76 additions & 1 deletion

File tree

internal/achhelp/id_test.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package achhelp_test
2+
3+
import (
4+
"path/filepath"
5+
"testing"
6+
7+
"github.com/moov-io/ach"
8+
"github.com/moov-io/rail-msg-sql/internal/achhelp"
9+
10+
"github.com/stretchr/testify/require"
11+
)
12+
13+
func TestPopulatedIDs(t *testing.T) {
14+
file, err := ach.ReadFile(filepath.Join("..", "search", "testdata", "ach", "ppd-debit.ach"))
15+
require.NoError(t, err)
16+
17+
file = achhelp.PopulateIDs(file)
18+
require.NotNil(t, file)
19+
20+
// File ID
21+
require.Equal(t, "5256dc55cab0a28d9ee8d2ccddec55d97477372573caff4de56ce85bee0f0a7b", file.ID)
22+
23+
// Batch ID
24+
require.Equal(t, "7cf510873dc46d322fd93777487472d1efed4d4e3bdbccb0e8068ff108eddd7b", file.Batches[0].ID())
25+
26+
// Entry ID
27+
entries := file.Batches[0].GetEntries()
28+
require.Equal(t, "7d47b497f775a8957ae3a9a58e94bc5fa1acdacfa17b644019c3f715671c3f4e", entries[0].ID)
29+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package storage_test
2+
3+
import (
4+
"context"
5+
"path/filepath"
6+
"testing"
7+
"time"
8+
9+
"github.com/moov-io/ach"
10+
achwebviewer "github.com/moov-io/ach-web-viewer/pkg/service"
11+
"github.com/moov-io/rail-msg-sql/internal/storage"
12+
13+
"github.com/stretchr/testify/require"
14+
)
15+
16+
func TestRepository(t *testing.T) {
17+
repo, err := storage.NewRepository(storage.Config{
18+
ACH: achwebviewer.Sources{
19+
{
20+
Filesystem: &achwebviewer.FilesystemConfig{
21+
Paths: []string{
22+
filepath.Join("testdata", "ach"),
23+
},
24+
},
25+
},
26+
},
27+
ACHValidateOpts: &ach.ValidateOpts{
28+
AllowMissingFileHeader: true,
29+
AllowMissingFileControl: true,
30+
},
31+
})
32+
require.NoError(t, err)
33+
34+
// Change dir so filelist package lets us read the dir
35+
t.Chdir(filepath.Join("..", "search"))
36+
37+
ctx := context.Background()
38+
params := storage.FilterParams{
39+
StartDate: time.Date(2018, time.September, 1, 0, 0, 0, 0, time.UTC),
40+
EndDate: time.Date(2100, time.January, 1, 0, 0, 0, 0, time.UTC),
41+
}
42+
43+
files, err := repo.ListAchFiles(ctx, params)
44+
require.NoError(t, err)
45+
require.Greater(t, len(files), 5)
46+
}

makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ ifeq ($(OS),Windows_NT)
3535
else
3636
@wget -O lint-project.sh https://raw.githubusercontent.com/moov-io/infra/master/go/lint-project.sh
3737
@chmod +x ./lint-project.sh
38-
COVER_THRESHOLD=40.0 ./lint-project.sh
38+
COVER_THRESHOLD=50.0 ./lint-project.sh
3939
endif
4040

4141
.PHONY: teardown

0 commit comments

Comments
 (0)