summaryrefslogtreecommitdiff
path: root/integrationtests/dgrep_test.go
diff options
context:
space:
mode:
authorPaul Buetow <pbuetow@mimecast.com>2021-10-21 21:28:49 +0300
committerPaul Buetow <pbuetow@mimecast.com>2021-10-21 21:28:49 +0300
commitf4207a55f71bfbcfdc532d5cdd3befaa3474a157 (patch)
treeea5e4a2d2a67035f645bdee496ae55a52034178a /integrationtests/dgrep_test.go
parentd80d6070557e3a800e3a54967af9eced518f116b (diff)
parent739205206d63bf42f4e843b39d04d4c8cd8207c3 (diff)
merge develop
Diffstat (limited to 'integrationtests/dgrep_test.go')
-rw-r--r--integrationtests/dgrep_test.go110
1 files changed, 110 insertions, 0 deletions
diff --git a/integrationtests/dgrep_test.go b/integrationtests/dgrep_test.go
new file mode 100644
index 0000000..8fe0a49
--- /dev/null
+++ b/integrationtests/dgrep_test.go
@@ -0,0 +1,110 @@
+package integrationtests
+
+import (
+ "context"
+ "os"
+ "testing"
+
+ "github.com/mimecast/dtail/internal/config"
+)
+
+func TestDGrep(t *testing.T) {
+ if !config.Env("DTAIL_RUN_INTEGRATION_TESTS") {
+ t.Log("Skipping")
+ return
+ }
+ inFile := "mapr_testdata.log"
+ stdoutFile := "dgrep.stdout.tmp"
+ expectedStdoutFile := "dgrep.txt.expected"
+
+ _, err := runCommand(context.TODO(), t, stdoutFile,
+ "../dgrep", "--spartan", "--grep", "20211002-071947", inFile)
+
+ if err != nil {
+ t.Error(err)
+ return
+ }
+
+ if err := compareFiles(t, stdoutFile, expectedStdoutFile); err != nil {
+ t.Error(err)
+ return
+ }
+
+ os.Remove(stdoutFile)
+}
+
+func TestDGrep2(t *testing.T) {
+ if !config.Env("DTAIL_RUN_INTEGRATION_TESTS") {
+ t.Log("Skipping")
+ return
+ }
+ inFile := "mapr_testdata.log"
+ stdoutFile := "dgrep2.stdout.tmp"
+ expectedStdoutFile := "dgrep2.txt.expected"
+
+ _, err := runCommand(context.TODO(), t, stdoutFile,
+ "../dgrep", "-spartan", "--grep", "20211002-071947", "--invert", inFile)
+
+ if err != nil {
+ t.Error(err)
+ return
+ }
+
+ if err := compareFiles(t, stdoutFile, expectedStdoutFile); err != nil {
+ t.Error(err)
+ return
+ }
+
+ os.Remove(stdoutFile)
+}
+
+func TestDGrepContext(t *testing.T) {
+ if !config.Env("DTAIL_RUN_INTEGRATION_TESTS") {
+ t.Log("Skipping")
+ return
+ }
+ inFile := "mapr_testdata.log"
+ stdoutFile := "dgrepcontext.stdout.tmp"
+ expectedStdoutFile := "dgrepcontext.txt.expected"
+
+ _, err := runCommand(context.TODO(), t, stdoutFile,
+ "../dgrep", "--spartan", "--grep", "20211002-071947",
+ "-after", "3", "-before", "3", inFile)
+
+ if err != nil {
+ t.Error(err)
+ return
+ }
+
+ if err := compareFiles(t, stdoutFile, expectedStdoutFile); err != nil {
+ t.Error(err)
+ return
+ }
+
+ os.Remove(stdoutFile)
+}
+
+func TestDGrepContext2(t *testing.T) {
+ if !config.Env("DTAIL_RUN_INTEGRATION_TESTS") {
+ t.Log("Skipping")
+ return
+ }
+ inFile := "mapr_testdata.log"
+ stdoutFile := "dgrepcontext2.stdout.tmp"
+ expectedStdoutFile := "dgrepcontext2.txt.expected"
+
+ _, err := runCommand(context.TODO(), t, stdoutFile,
+ "../dgrep", "--spartan", "--grep", "20211002", "-max", "3", inFile)
+
+ if err != nil {
+ t.Error(err)
+ return
+ }
+
+ if err := compareFiles(t, stdoutFile, expectedStdoutFile); err != nil {
+ t.Error(err)
+ return
+ }
+
+ os.Remove(stdoutFile)
+}