feat(go): qualify tdengine history writes by database
This commit is contained in:
@@ -261,6 +261,30 @@ func TestWriterAppendsBatchRowsByChildTable(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestWriterWithDatabaseQualifiesTDengineTables(t *testing.T) {
|
||||
exec := &recordingExec{}
|
||||
writer := NewWriterWithDatabase(exec, "vehicle_ts")
|
||||
env := sampleEnvelope()
|
||||
|
||||
if err := writer.AppendAll(context.Background(), env); err != nil {
|
||||
t.Fatalf("AppendAll() error = %v", err)
|
||||
}
|
||||
|
||||
for _, want := range []string{
|
||||
"CREATE TABLE IF NOT EXISTS vehicle_ts.raw_",
|
||||
"USING vehicle_ts.raw_frames",
|
||||
"ALTER TABLE vehicle_ts.raw_",
|
||||
"INSERT INTO vehicle_ts.raw_",
|
||||
"CREATE TABLE IF NOT EXISTS vehicle_ts.loc_",
|
||||
"USING vehicle_ts.vehicle_locations",
|
||||
"INSERT INTO vehicle_ts.loc_",
|
||||
} {
|
||||
if !containsSQL(exec.calls, want) {
|
||||
t.Fatalf("qualified sql missing %q, calls=%v", want, exec.calls)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestWriterAppendAllBatchSkipsEmptyBatch(t *testing.T) {
|
||||
exec := &recordingExec{}
|
||||
writer := NewWriter(exec)
|
||||
@@ -338,6 +362,10 @@ func findSQL(calls []execCall, pattern string) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func containsSQL(calls []execCall, pattern string) bool {
|
||||
return findSQL(calls, pattern) != ""
|
||||
}
|
||||
|
||||
func between(value string, start string, end string) string {
|
||||
startIndex := strings.Index(value, start)
|
||||
if startIndex < 0 {
|
||||
|
||||
Reference in New Issue
Block a user