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)
| 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. |
| 1383 | func 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 | |
| 1399 | type fakeExecResult struct { |
nothing calls this directly
no test coverage detected