|
| 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 | +} |
0 commit comments