(t *testing.T)
| 692 | } |
| 693 | |
| 694 | func TestScanErrorContext(t *testing.T) { |
| 695 | var schema = Schema{ |
| 696 | create: ` |
| 697 | CREATE TABLE kv ( |
| 698 | k text, |
| 699 | v integer |
| 700 | );`, |
| 701 | drop: `drop table kv;`, |
| 702 | } |
| 703 | |
| 704 | RunWithSchemaContext(context.Background(), schema, t, func(ctx context.Context, db *DB, t *testing.T) { |
| 705 | type WrongTypes struct { |
| 706 | K int |
| 707 | V string |
| 708 | } |
| 709 | _, err := db.Exec(db.Rebind("INSERT INTO kv (k, v) VALUES (?, ?)"), "hi", 1) |
| 710 | if err != nil { |
| 711 | t.Error(err) |
| 712 | } |
| 713 | |
| 714 | rows, err := db.QueryxContext(ctx, "SELECT * FROM kv") |
| 715 | if err != nil { |
| 716 | t.Error(err) |
| 717 | } |
| 718 | for rows.Next() { |
| 719 | var wt WrongTypes |
| 720 | err := rows.StructScan(&wt) |
| 721 | if err == nil { |
| 722 | t.Errorf("%s: Scanning wrong types into keys should have errored.", db.DriverName()) |
| 723 | } |
| 724 | } |
| 725 | }) |
| 726 | } |
| 727 | |
| 728 | // FIXME: this function is kinda big but it slows things down to be constantly |
| 729 | // loading and reloading the schema.. |
nothing calls this directly
no test coverage detected