summaryrefslogtreecommitdiff
path: root/integrationtests/dcat_test.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2021-11-02 08:11:40 +0200
committerPaul Buetow <paul@buetow.org>2021-11-02 08:11:40 +0200
commit1ec88deea93047a9d1a366e032b2a54aa3cd362b (patch)
tree465f30673aa097a2b369e7c3d2032b041ff4f8e6 /integrationtests/dcat_test.go
parent2e9ce81c47d45dd1f2c607df6e19bdfdc3bb3cc8 (diff)
Bugfix: Dealing correctly with files without newline characters, also add more tests
Diffstat (limited to 'integrationtests/dcat_test.go')
-rw-r--r--integrationtests/dcat_test.go55
1 files changed, 31 insertions, 24 deletions
diff --git a/integrationtests/dcat_test.go b/integrationtests/dcat_test.go
index 124cb62..bef5db2 100644
--- a/integrationtests/dcat_test.go
+++ b/integrationtests/dcat_test.go
@@ -8,57 +8,64 @@ import (
"github.com/mimecast/dtail/internal/config"
)
-func TestDCat(t *testing.T) {
+func TestDCat1(t *testing.T) {
if !config.Env("DTAIL_INTEGRATION_TEST_RUN_MODE") {
t.Log("Skipping")
return
}
- testdataFile := "dcat.txt"
- stdoutFile := "dcat.out"
- _, err := runCommand(context.TODO(), t, stdoutFile,
- "../dcat", "--plain", "--cfg", "none", testdataFile)
+ 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 {
- t.Error(err)
- return
+ return err
}
-
- if err := compareFiles(t, stdoutFile, testdataFile); err != nil {
- t.Error(err)
- return
+ if err := compareFiles(t, outFile, inFile); err != nil {
+ return err
}
- os.Remove(stdoutFile)
+ os.Remove(outFile)
+ return nil
}
func TestDCat2(t *testing.T) {
if !config.Env("DTAIL_INTEGRATION_TEST_RUN_MODE") {
return
}
- testdataFile := "dcat2.txt"
+ inFile := "dcat2.txt"
expectedFile := "dcat2.txt.expected"
- stdoutFile := "dcat2.out"
+ 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, testdataFile)
+ args = append(args, inFile)
}
- _, err := runCommand(context.TODO(), t, stdoutFile, "../dcat", args...)
+ _, err := runCommand(context.TODO(), t, outFile, "../dcat", args...)
if err != nil {
t.Error(err)
return
}
- if err := compareFilesContents(t, stdoutFile, expectedFile); err != nil {
+ if err := compareFilesContents(t, outFile, expectedFile); err != nil {
t.Error(err)
return
}
- os.Remove(stdoutFile)
+ os.Remove(outFile)
}
func TestDCatColors(t *testing.T) {
@@ -66,22 +73,22 @@ func TestDCatColors(t *testing.T) {
return
}
- testdataFile := "dcatcolors.txt"
- stdoutFile := "dcatcolors.out"
+ inFile := "dcatcolors.txt"
+ outFile := "dcatcolors.out"
expectedFile := "dcatcolors.expected"
- _, err := runCommand(context.TODO(), t, stdoutFile,
- "../dcat", "--logLevel", "error", "--cfg", "none", testdataFile)
+ _, err := runCommand(context.TODO(), t, outFile,
+ "../dcat", "--logLevel", "error", "--cfg", "none", inFile)
if err != nil {
t.Error(err)
return
}
- if err := compareFiles(t, stdoutFile, expectedFile); err != nil {
+ if err := compareFiles(t, outFile, expectedFile); err != nil {
t.Error(err)
return
}
- os.Remove(stdoutFile)
+ os.Remove(outFile)
}