summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <pbuetow@mimecast.com>2021-12-08 09:52:21 +0000
committerPaul Buetow <pbuetow@mimecast.com>2021-12-08 09:52:21 +0000
commite70adfe0d309d511ae7598683003c92795192fe1 (patch)
tree25c8dd5073d8021f1de927a5ee236003cd63457c
parentbdf066311ae1ec552f2f4bff6f269817b8052718 (diff)
refactor dmap1 unit test to be more modular
-rw-r--r--integrationtests/dmap1a.csv.expected (renamed from integrationtests/dmap1.csv.expected)0
-rw-r--r--integrationtests/dmap1a.csv.query.expected (renamed from integrationtests/dmap1.csv.query.expected)2
-rw-r--r--integrationtests/dmap_test.go21
3 files changed, 12 insertions, 11 deletions
diff --git a/integrationtests/dmap1.csv.expected b/integrationtests/dmap1a.csv.expected
index d4e6f0f..d4e6f0f 100644
--- a/integrationtests/dmap1.csv.expected
+++ b/integrationtests/dmap1a.csv.expected
diff --git a/integrationtests/dmap1.csv.query.expected b/integrationtests/dmap1a.csv.query.expected
index f47670a..dcc63ca 100644
--- a/integrationtests/dmap1.csv.query.expected
+++ b/integrationtests/dmap1a.csv.query.expected
@@ -1 +1 @@
-from STATS select count($line),last($time),avg($goroutines),min(concurrentConnections),max(lifetimeConnections) group by $hostname outfile dmap1.csv.tmp \ No newline at end of file
+from STATS select count($line),last($time),avg($goroutines),min(concurrentConnections),max(lifetimeConnections) group by $hostname outfile dmap1a.csv.tmp \ No newline at end of file
diff --git a/integrationtests/dmap_test.go b/integrationtests/dmap_test.go
index 5e5f4d3..ec14cfb 100644
--- a/integrationtests/dmap_test.go
+++ b/integrationtests/dmap_test.go
@@ -15,28 +15,29 @@ func TestDMap1(t *testing.T) {
return
}
+ query := fmt.Sprintf("from STATS select count($line),last($time)," +
+ "avg($goroutines),min(concurrentConnections),max(lifetimeConnections) " +
+ "group by $hostname")
+
t.Log("Testing dmap with input file")
- if err := testDmap1(t, false); err != nil {
+ if err := testDmap1(t, query, "a", false); err != nil {
t.Error(err)
return
}
t.Log("Testing dmap with stdin input pipe")
- if err := testDmap1(t, true); err != nil {
+ if err := testDmap1(t, query, "a", true); err != nil {
t.Error(err)
return
}
}
-func testDmap1(t *testing.T, usePipe bool) error {
+func testDmap1(t *testing.T, query, subtestName string, usePipe bool) error {
inFile := "mapr_testdata.log"
- csvFile := "dmap1.csv.tmp"
- expectedCsvFile := "dmap1.csv.expected"
+ csvFile := fmt.Sprintf("dmap1%s.csv.tmp", subtestName)
+ expectedCsvFile := fmt.Sprintf("dmap1%s.csv.expected", subtestName)
queryFile := fmt.Sprintf("%s.query", csvFile)
- expectedQueryFile := "dmap1.csv.query.expected"
-
- query := fmt.Sprintf("from STATS select count($line),last($time),"+
- "avg($goroutines),min(concurrentConnections),max(lifetimeConnections) "+
- "group by $hostname outfile %s", csvFile)
+ expectedQueryFile := fmt.Sprintf("dmap1%s.csv.query.expected", subtestName)
+ query = fmt.Sprintf("%s outfile %s", query, csvFile)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()