From bd4a2b1f012edb20d6df7e89ef1d8fdb5be0926f Mon Sep 17 00:00:00 2001 From: aThorp96 Date: Wed, 2 Jan 2019 13:20:42 -0500 Subject: [PATCH] Added tests for wildcard extension in include paths --- ledgerReader_test.go | 21 +++++++++++++++++++++ testdata/ledgerReader_expected_wildcard | 13 +++++++++++++ testdata/ledgerReader_input_wildcard_1 | 3 +++ testdata/ledgerReader_input_wildcard_2 | 3 +++ testdata/ledgerReader_input_wildcard_root | 4 ++++ 5 files changed, 44 insertions(+) create mode 100644 testdata/ledgerReader_expected_wildcard create mode 100644 testdata/ledgerReader_input_wildcard_1 create mode 100644 testdata/ledgerReader_input_wildcard_2 create mode 100644 testdata/ledgerReader_input_wildcard_root diff --git a/ledgerReader_test.go b/ledgerReader_test.go index ae9df035..51d96805 100644 --- a/ledgerReader_test.go +++ b/ledgerReader_test.go @@ -51,6 +51,27 @@ func TestLedgerScannerSingleInclude(t *testing.T) { } } +func TestLedgerScannerWildcardInclude(t *testing.T) { + r, err := NewLedgerReader("testdata/ledgerReader_input_1_root") + if err != nil { + t.Fatal(err) + } + + parsed, err := ioutil.ReadAll(r) + if err != nil { + t.Fatal(err) + } + + expected, _ := ioutil.ReadFile(filepath.Join("testdata", "ledgerReader_expected_1")) + if err != nil { + t.Fatal(err) + } + + if !bytes.Equal(parsed, expected) { + t.Fatalf("expected:\n%s\n\n got:\n%s", expected, parsed) + } +} + func TestMarkerSplit(t *testing.T) { filename, lineNum := parseMarker(";__ledger_file*-*/somedir/somefile*-*45") if filename != "/somedir/somefile" { diff --git a/testdata/ledgerReader_expected_wildcard b/testdata/ledgerReader_expected_wildcard new file mode 100644 index 00000000..4bbbbc30 --- /dev/null +++ b/testdata/ledgerReader_expected_wildcard @@ -0,0 +1,13 @@ +;__ledger_file*-*testdata/ledgerReader_input_root_wildcard*-*0 +the +quick +;__ledger_file*-*testdata/ledgerReader_input_wildcard_1*-*0 +brown +fox +jumps +;__ledger_file*-*testdata/ledgerReader_input_wildcard_2*-*0 +over +the +;__ledger_file*-*testdata/ledgerReader_input_1_root*-*3 +lazy +dog diff --git a/testdata/ledgerReader_input_wildcard_1 b/testdata/ledgerReader_input_wildcard_1 new file mode 100644 index 00000000..a98528f8 --- /dev/null +++ b/testdata/ledgerReader_input_wildcard_1 @@ -0,0 +1,3 @@ +jumps +over +the diff --git a/testdata/ledgerReader_input_wildcard_2 b/testdata/ledgerReader_input_wildcard_2 new file mode 100644 index 00000000..a98528f8 --- /dev/null +++ b/testdata/ledgerReader_input_wildcard_2 @@ -0,0 +1,3 @@ +jumps +over +the diff --git a/testdata/ledgerReader_input_wildcard_root b/testdata/ledgerReader_input_wildcard_root new file mode 100644 index 00000000..39c2d65a --- /dev/null +++ b/testdata/ledgerReader_input_wildcard_root @@ -0,0 +1,4 @@ +the +include ledgerReader_input_wildcard* +lazy +dog