(t *testing.T)
| 1303 | } |
| 1304 | |
| 1305 | func TestEmbeddedLiteralsContext(t *testing.T) { |
| 1306 | var schema = Schema{ |
| 1307 | create: ` |
| 1308 | CREATE TABLE x ( |
| 1309 | k text |
| 1310 | );`, |
| 1311 | drop: `drop table x;`, |
| 1312 | } |
| 1313 | |
| 1314 | RunWithSchemaContext(context.Background(), schema, t, func(ctx context.Context, db *DB, t *testing.T) { |
| 1315 | type t1 struct { |
| 1316 | K *string |
| 1317 | } |
| 1318 | type t2 struct { |
| 1319 | Inline struct { |
| 1320 | F string |
| 1321 | } |
| 1322 | K *string |
| 1323 | } |
| 1324 | |
| 1325 | db.MustExecContext(ctx, db.Rebind("INSERT INTO x (k) VALUES (?), (?), (?);"), "one", "two", "three") |
| 1326 | |
| 1327 | target := t1{} |
| 1328 | err := db.GetContext(ctx, &target, db.Rebind("SELECT * FROM x WHERE k=?"), "one") |
| 1329 | if err != nil { |
| 1330 | t.Error(err) |
| 1331 | } |
| 1332 | if *target.K != "one" { |
| 1333 | t.Error("Expected target.K to be `one`, got ", target.K) |
| 1334 | } |
| 1335 | |
| 1336 | target2 := t2{} |
| 1337 | err = db.GetContext(ctx, &target2, db.Rebind("SELECT * FROM x WHERE k=?"), "one") |
| 1338 | if err != nil { |
| 1339 | t.Error(err) |
| 1340 | } |
| 1341 | if *target2.K != "one" { |
| 1342 | t.Errorf("Expected target2.K to be `one`, got `%v`", target2.K) |
| 1343 | } |
| 1344 | }) |
| 1345 | } |
| 1346 | |
| 1347 | func TestConn(t *testing.T) { |
| 1348 | var schema = Schema{ |
nothing calls this directly
no test coverage detected