diff options
| author | Paul Buetow <pbuetow@mimecast.com> | 2022-02-04 21:37:29 +0000 |
|---|---|---|
| committer | Paul Buetow <pbuetow@mimecast.com> | 2022-02-04 21:37:29 +0000 |
| commit | 1db3b5dc1219e34e0e1c612e6646327701c40274 (patch) | |
| tree | cab22128af9e54131facd0062a474459383a1c90 /integrationtests/dgrep_test.go | |
| parent | 6625d019271d3d7931587167845d77834d187d57 (diff) | |
| parent | cc6f19f69d0fb34af96e17147b2030c352d46845 (diff) | |
merge 4.0.0-RC
Diffstat (limited to 'integrationtests/dgrep_test.go')
| -rw-r--r-- | integrationtests/dgrep_test.go | 128 |
1 files changed, 128 insertions, 0 deletions
diff --git a/integrationtests/dgrep_test.go b/integrationtests/dgrep_test.go new file mode 100644 index 0000000..943f99e --- /dev/null +++ b/integrationtests/dgrep_test.go @@ -0,0 +1,128 @@ +package integrationtests + +import ( + "context" + "os" + "testing" + + "github.com/mimecast/dtail/internal/config" +) + +func TestDGrep1(t *testing.T) { + if !config.Env("DTAIL_INTEGRATION_TEST_RUN_MODE") { + t.Log("Skipping") + return + } + inFile := "mapr_testdata.log" + outFile := "dgrep.stdout.tmp" + expectedOutFile := "dgrep1.txt.expected" + + _, err := runCommand(context.TODO(), t, outFile, + "../dgrep", + "--plain", + "--cfg", "none", + "--grep", "1002-071947", + inFile) + + if err != nil { + t.Error(err) + return + } + + if err := compareFiles(t, outFile, expectedOutFile); err != nil { + t.Error(err) + return + } + + os.Remove(outFile) +} + +func TestDGrep2(t *testing.T) { + if !config.Env("DTAIL_INTEGRATION_TEST_RUN_MODE") { + t.Log("Skipping") + return + } + inFile := "mapr_testdata.log" + outFile := "dgrep2.stdout.tmp" + expectedOutFile := "dgrep2.txt.expected" + + _, err := runCommand(context.TODO(), t, outFile, + "../dgrep", + "--plain", + "--cfg", "none", + "--grep", "1002-071947", + "--invert", + inFile) + + if err != nil { + t.Error(err) + return + } + + if err := compareFiles(t, outFile, expectedOutFile); err != nil { + t.Error(err) + return + } + + os.Remove(outFile) +} + +func TestDGrepContext1(t *testing.T) { + if !config.Env("DTAIL_INTEGRATION_TEST_RUN_MODE") { + t.Log("Skipping") + return + } + inFile := "mapr_testdata.log" + outFile := "dgrepcontext1.stdout.tmp" + expectedOutFile := "dgrepcontext1.txt.expected" + + _, err := runCommand(context.TODO(), t, outFile, + "../dgrep", + "--plain", + "--cfg", "none", + "--grep", "1002-071947", + "--after", "3", + "--before", "3", inFile) + + if err != nil { + t.Error(err) + return + } + + if err := compareFiles(t, outFile, expectedOutFile); err != nil { + t.Error(err) + return + } + + os.Remove(outFile) +} + +func TestDGrepContext2(t *testing.T) { + if !config.Env("DTAIL_INTEGRATION_TEST_RUN_MODE") { + t.Log("Skipping") + return + } + inFile := "mapr_testdata.log" + outFile := "dgrepcontext2.stdout.tmp" + expectedOutFile := "dgrepcontext2.txt.expected" + + _, err := runCommand(context.TODO(), t, outFile, + "../dgrep", + "--plain", + "--cfg", "none", + "--grep", "1002", + "--max", "3", + inFile) + + if err != nil { + t.Error(err) + return + } + + if err := compareFiles(t, outFile, expectedOutFile); err != nil { + t.Error(err) + return + } + + os.Remove(outFile) +} |
