MCPcopy Create free account
hub / github.com/PostHog/duckgres / TestBuildCommandTagConsistency

Function TestBuildCommandTagConsistency

server/conn_test.go:1382–1396  ·  view source on GitHub ↗

TestBuildCommandTagConsistency verifies that buildCommandTagFromRowCount produces the same tags as buildCommandTag for DML types. This ensures the Query path (used for DML RETURNING) and the Exec path produce identical command tags.

(t *testing.T)

Source from the content-addressed store, hash-verified

1380// TestBuildCommandTagConsistency verifies that buildCommandTagFromRowCount produces
1381// the same tags as buildCommandTag for DML types. This ensures the Query path
1382// (used for DML RETURNING) and the Exec path produce identical command tags.
1383func TestBuildCommandTagConsistency(t *testing.T) {
1384 c := &clientConn{}
1385 for _, cmdType := range []string{"INSERT", "UPDATE", "DELETE"} {
1386 for _, count := range []int64{0, 1, 5, 100} {
1387 t.Run(fmt.Sprintf("%s_%d", cmdType, count), func(t *testing.T) {
1388 fromRowCount := buildCommandTagFromRowCount(cmdType, count)
1389 fromExecResult := c.buildCommandTag(cmdType, &fakeExecResult{rowsAffected: count})
1390 if fromRowCount != fromExecResult {
1391 t.Errorf("tag mismatch for %s/%d: fromRowCount=%q, fromExecResult=%q",
1392 cmdType, count, fromRowCount, fromExecResult)
1393 }
1394 })
1395 }
1396 }
1397}
1398
1399type fakeExecResult struct {

Callers

nothing calls this directly

Calls 3

buildCommandTagMethod · 0.95
RunMethod · 0.65

Tested by

no test coverage detected