diff options
| author | Paul Buetow <pbuetow@mimecast.com> | 2021-10-15 12:38:39 +0300 |
|---|---|---|
| committer | Paul Buetow <pbuetow@mimecast.com> | 2021-10-15 12:38:39 +0300 |
| commit | 55ba72efa4e5d2363f8e0c2cf729c596e760e1c3 (patch) | |
| tree | 72618e384626d9fc368994e3f24be9e9892d0610 /integrationtests/dgrep_test.go | |
| parent | dccbee7dc355438d87baff45e054848e508b004d (diff) | |
| parent | d3549a3316a9917520ab5e6b0cd7b1846c59ad4b (diff) | |
merge from github.com/snonux/dtail
Diffstat (limited to 'integrationtests/dgrep_test.go')
| -rw-r--r-- | integrationtests/dgrep_test.go | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/integrationtests/dgrep_test.go b/integrationtests/dgrep_test.go new file mode 100644 index 0000000..b63ac45 --- /dev/null +++ b/integrationtests/dgrep_test.go @@ -0,0 +1,92 @@ +package integrationtests + +import ( + "context" + "os" + "testing" +) + +func TestDGrep(t *testing.T) { + 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) { + 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) { + 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) { + 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) +} |
