(t *testing.T)
| 1422 | } |
| 1423 | |
| 1424 | func TestEmbeddedMaps(t *testing.T) { |
| 1425 | var schema = Schema{ |
| 1426 | create: ` |
| 1427 | CREATE TABLE message ( |
| 1428 | string text, |
| 1429 | properties text |
| 1430 | );`, |
| 1431 | drop: `drop table message;`, |
| 1432 | } |
| 1433 | |
| 1434 | RunWithSchema(schema, t, func(db *DB, t *testing.T, now string) { |
| 1435 | messages := []Message{ |
| 1436 | {"Hello, World", PropertyMap{"one": "1", "two": "2"}}, |
| 1437 | {"Thanks, Joy", PropertyMap{"pull": "request"}}, |
| 1438 | } |
| 1439 | q1 := `INSERT INTO message (string, properties) VALUES (:string, :properties);` |
| 1440 | for _, m := range messages { |
| 1441 | _, err := db.NamedExec(q1, m) |
| 1442 | if err != nil { |
| 1443 | t.Fatal(err) |
| 1444 | } |
| 1445 | } |
| 1446 | var count int |
| 1447 | err := db.Get(&count, "SELECT count(*) FROM message") |
| 1448 | if err != nil { |
| 1449 | t.Fatal(err) |
| 1450 | } |
| 1451 | if count != len(messages) { |
| 1452 | t.Fatalf("Expected %d messages in DB, found %d", len(messages), count) |
| 1453 | } |
| 1454 | |
| 1455 | var m Message |
| 1456 | err = db.Get(&m, "SELECT * FROM message LIMIT 1;") |
| 1457 | if err != nil { |
| 1458 | t.Fatal(err) |
| 1459 | } |
| 1460 | if m.Properties == nil { |
| 1461 | t.Fatal("Expected m.Properties to not be nil, but it was.") |
| 1462 | } |
| 1463 | }) |
| 1464 | } |
| 1465 | |
| 1466 | func TestIssue197(t *testing.T) { |
| 1467 | // this test actually tests for a bug in database/sql: |
nothing calls this directly
no test coverage detected