fix(go): normalize tdengine phone tags

This commit is contained in:
lingniu
2026-07-02 13:43:15 +08:00
parent 75e7c3fbe5
commit b27f909109
2 changed files with 36 additions and 1 deletions

View File

@@ -54,6 +54,28 @@ func TestWriterAppendsRawLocationAndMileage(t *testing.T) {
}
}
func TestWriterNormalizesPhoneTagAndRefreshesExistingChildTags(t *testing.T) {
exec := &recordingExec{}
writer := NewWriter(exec)
env := sampleEnvelope()
if err := writer.AppendRawFrame(context.Background(), env); err != nil {
t.Fatalf("AppendRawFrame() error = %v", err)
}
createChild := findSQL(exec.calls, "USING raw_frames")
if !strings.Contains(createChild, "'13307795425'") {
t.Fatalf("child table phone tag should be normalized: %s", createChild)
}
if strings.Contains(createChild, "'013307795425'") {
t.Fatalf("child table phone tag should not keep leading zero: %s", createChild)
}
refreshTag := findSQL(exec.calls, "SET TAG phone")
if !strings.Contains(refreshTag, "'13307795425'") {
t.Fatalf("phone tag refresh should use normalized phone: %s", refreshTag)
}
}
func TestWriterChunksOversizedParsedJSON(t *testing.T) {
exec := &recordingExec{}
writer := NewWriter(exec)