MCPcopy
hub / github.com/go-sql-driver/mysql / TestColumnsReusesSlice

Function TestColumnsReusesSlice

driver_test.go:2256–2287  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2254}
2255
2256func TestColumnsReusesSlice(t *testing.T) {
2257 rows := mysqlRows{
2258 rs: resultSet{
2259 columns: []mysqlField{
2260 {
2261 tableName: "test",
2262 name: "A",
2263 },
2264 {
2265 tableName: "test",
2266 name: "B",
2267 },
2268 },
2269 },
2270 }
2271
2272 allocs := testing.AllocsPerRun(1, func() {
2273 cols := rows.Columns()
2274
2275 if len(cols) != 2 {
2276 t.Fatalf("expected 2 columns, got %d", len(cols))
2277 }
2278 })
2279
2280 if allocs != 0 {
2281 t.Fatalf("expected 0 allocations, got %d", int(allocs))
2282 }
2283
2284 if rows.rs.columnNames == nil {
2285 t.Fatalf("expected columnNames to be set, got nil")
2286 }
2287}
2288
2289func TestRejectReadOnly(t *testing.T) {
2290 runTests(t, dsn, func(dbt *DBTest) {

Callers

nothing calls this directly

Calls 1

ColumnsMethod · 0.95

Tested by

no test coverage detected