feat(go): persist full raw payload chunks
This commit is contained in:
@@ -54,6 +54,30 @@ func TestWriterAppendsRawLocationAndMileage(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestWriterChunksOversizedParsedJSON(t *testing.T) {
|
||||
exec := &recordingExec{}
|
||||
writer := NewWriter(exec)
|
||||
env := sampleEnvelope()
|
||||
env.Parsed = map[string]any{
|
||||
"large_payload": strings.Repeat("x", 16_128),
|
||||
}
|
||||
|
||||
if err := writer.AppendRawFrame(context.Background(), env); err != nil {
|
||||
t.Fatalf("AppendRawFrame() error = %v", err)
|
||||
}
|
||||
|
||||
rawInsert := findSQL(exec.calls, "INSERT INTO raw_")
|
||||
if !strings.Contains(rawInsert, `"chunked":true`) || !strings.Contains(rawInsert, `"payload_kind":"parsed_json"`) {
|
||||
t.Fatalf("raw insert should store a parsed_json chunk manifest: %s", rawInsert)
|
||||
}
|
||||
if got := countSQL(exec.calls, "USING raw_frame_payload_chunks"); got != 1 {
|
||||
t.Fatalf("chunk child create count = %d", got)
|
||||
}
|
||||
if got := countSQL(exec.calls, "INSERT INTO chunk_"); got < 2 {
|
||||
t.Fatalf("chunk insert count = %d, calls=%v", got, exec.calls)
|
||||
}
|
||||
}
|
||||
|
||||
func TestWriterSkipsSparseDerivedRows(t *testing.T) {
|
||||
exec := &recordingExec{}
|
||||
writer := NewWriter(exec)
|
||||
@@ -87,6 +111,15 @@ func TestRawSizeBytesUsesRawTextWhenHexIsEmpty(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSchemaStatementsCreateRawFramePayloadChunks(t *testing.T) {
|
||||
statements := strings.Join(SchemaStatements("test_ts"), "\n")
|
||||
for _, want := range []string{"raw_frame_payload_chunks", "payload_kind NCHAR(32)", "chunk_index INT", "chunk_text BINARY(16000)"} {
|
||||
if !strings.Contains(statements, want) {
|
||||
t.Fatalf("schema missing %q:\n%s", want, statements)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func sampleEnvelope() envelope.FrameEnvelope {
|
||||
return envelope.FrameEnvelope{
|
||||
Protocol: envelope.ProtocolJT808,
|
||||
|
||||
Reference in New Issue
Block a user