summaryrefslogtreecommitdiff
path: root/integrationtests/dcat_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'integrationtests/dcat_test.go')
-rw-r--r--integrationtests/dcat_test.go120
1 files changed, 120 insertions, 0 deletions
diff --git a/integrationtests/dcat_test.go b/integrationtests/dcat_test.go
new file mode 100644
index 0000000..b2a041c
--- /dev/null
+++ b/integrationtests/dcat_test.go
@@ -0,0 +1,120 @@
+package integrationtests
+
+import (
+ "context"
+ "os"
+ "testing"
+
+ "github.com/mimecast/dtail/internal/config"
+)
+
+func TestDCat1(t *testing.T) {
+ if !config.Env("DTAIL_INTEGRATION_TEST_RUN_MODE") {
+ t.Log("Skipping")
+ return
+ }
+
+ inFiles := []string{"dcat1a.txt", "dcat1b.txt", "dcat1c.txt", "dcat1d.txt"}
+ for _, inFile := range inFiles {
+ if err := testDCat1(t, inFile); err != nil {
+ t.Error(err)
+ return
+ }
+ }
+}
+
+func testDCat1(t *testing.T, inFile string) error {
+ outFile := "dcat1.out"
+
+ _, err := runCommand(context.TODO(), t, outFile,
+ "../dcat", "--plain", "--cfg", "none", inFile)
+ if err != nil {
+ return err
+ }
+ if err := compareFiles(t, outFile, inFile); err != nil {
+ return err
+ }
+
+ os.Remove(outFile)
+ return nil
+}
+
+func TestDCat2(t *testing.T) {
+ if !config.Env("DTAIL_INTEGRATION_TEST_RUN_MODE") {
+ return
+ }
+ inFile := "dcat2.txt"
+ expectedFile := "dcat2.txt.expected"
+ outFile := "dcat2.out"
+
+ args := []string{"--plain", "--logLevel", "error", "--cfg", "none"}
+
+ // Cat file 100 times in one session.
+ for i := 0; i < 100; i++ {
+ args = append(args, inFile)
+ }
+
+ _, err := runCommand(context.TODO(), t, outFile, "../dcat", args...)
+ if err != nil {
+ t.Error(err)
+ return
+ }
+
+ if err := compareFilesContents(t, outFile, expectedFile); err != nil {
+ t.Error(err)
+ return
+ }
+
+ os.Remove(outFile)
+}
+
+func TestDCat3(t *testing.T) {
+ if !config.Env("DTAIL_INTEGRATION_TEST_RUN_MODE") {
+ return
+ }
+ inFile := "dcat3.txt"
+ expectedFile := "dcat3.txt.expected"
+ outFile := "dcat3.out"
+
+ args := []string{"--plain", "--logLevel", "error", "--cfg", "none", inFile}
+
+ // Notice, with DTAIL_INTEGRATION_TEST_RUN_MODE the DTail max line length is set
+ // to 1024!
+ _, err := runCommand(context.TODO(), t, outFile, "../dcat", args...)
+ if err != nil {
+ t.Error(err)
+ return
+ }
+
+ if err := compareFilesContents(t, outFile, expectedFile); err != nil {
+ t.Error(err)
+ return
+ }
+
+ os.Remove(outFile)
+}
+
+func TestDCatColors(t *testing.T) {
+ if !config.Env("DTAIL_INTEGRATION_TEST_RUN_MODE") {
+ return
+ }
+
+ inFile := "dcatcolors.txt"
+ outFile := "dcatcolors.out"
+ expectedFile := "dcatcolors.expected"
+
+ _, err := runCommand(context.TODO(), t, outFile,
+ "../dcat", "--logLevel", "error", "--cfg", "none", inFile)
+
+ if err != nil {
+ t.Error(err)
+ return
+ }
+
+ if err := compareFiles(t, outFile, expectedFile); err != nil {
+ t.Error(err)
+ return
+ }
+
+ os.Remove(outFile)
+}