forked from PBWebMedia/airflow-prometheus-exporter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcollector_test.go
27 lines (20 loc) · 940 Bytes
/
collector_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package main
import (
"testing"
)
func TestFormulateEventTotalDataPreparedStatementMySQL(t *testing.T) {
expectedStmt := "SELECT COUNT(*), COALESCE(dag_id, ''), COALESCE(task_id, ''), event, MAX(id) FROM log WHERE id > ? GROUP BY dag_id, task_id, event"
dbDriver = "mysql"
returnedStmt := formulateEventTotalDataPreparedStatement()
if returnedStmt != expectedStmt {
t.Errorf("Returned SQL statement was incorrect, got: '%s', want: '%s'.", returnedStmt, expectedStmt)
}
}
func TestFormulateEventTotalDataPreparedStatementPostgresSQL(t *testing.T) {
expectedStmt := "SELECT COUNT(*), COALESCE(dag_id, ''), COALESCE(task_id, ''), event, MAX(id) FROM log WHERE id > $1 GROUP BY dag_id, task_id, event"
dbDriver = "postgres"
returnedStmt := formulateEventTotalDataPreparedStatement()
if returnedStmt != expectedStmt {
t.Errorf("Returned SQL statement was incorrect, got: '%s', want: '%s'.", returnedStmt, expectedStmt)
}
}