diff options
| author | Paul Buetow <paul@buetow.org> | 2025-06-24 18:29:13 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-06-24 18:29:13 +0300 |
| commit | 61b2a90aefee82da19ea5b388fb6112760833d97 (patch) | |
| tree | b53b04f296434afc9a71d5702363b6532d73f85c /integrationtests-old/dgrep_test.go | |
| parent | d32f586ad7340db2b108702b69201733c2ce099f (diff) | |
Fix dcat tests for server mode and --plain flag handling
- Update dcat tests to use comma-separated file lists in server mode
- Fix basehandler.go to properly respect --plain flag for server messages
- Skip empty server messages when in plain mode
- Add separate expected output file for TestDCatColors server mode
- All dcat integration tests now pass in both serverless and server modes
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat (limited to 'integrationtests-old/dgrep_test.go')
| -rw-r--r-- | integrationtests-old/dgrep_test.go | 128 |
1 files changed, 128 insertions, 0 deletions
diff --git a/integrationtests-old/dgrep_test.go b/integrationtests-old/dgrep_test.go new file mode 100644 index 0000000..943f99e --- /dev/null +++ b/integrationtests-old/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) +} |
