# HG changeset patch # User Christophe de Vienne <christophe@cdevienne.info> # Date 1736803305 -3600 # Mon Jan 13 22:21:45 2025 +0100 # Node ID 6a6bbb024bf5cd07682707b222e7f8a3ec49c16a # Parent 50adb735d16e1616de8f6e28b29a8e70a612649c # EXP-Topic pick-testdb-flags TestDB: add flags diff --git a/database/test.go b/database/test.go --- a/database/test.go +++ b/database/test.go @@ -44,6 +44,16 @@ ctx context.Context tb testing.TB lockConn *sqlx.Conn + + flags map[string]bool +} + +func (db *TestDB) GetFlag(name string) bool { + return db.flags[name] +} + +func (db *TestDB) SetFlag(name string, value bool) { + db.flags[name] = value } // SetTB changes the current tb and returns a function to restore the original one. @@ -131,7 +141,7 @@ success = true - return &TestDB{db, dsn, ctx, tb, c} + return &TestDB{db, dsn, ctx, tb, c, make(map[string]bool)} } // GetTestDB creates a db and returns it. It must be closed within the test. @@ -200,7 +210,7 @@ } } - testDB := TestDB{db, dsn, ctx, tb, c} + testDB := TestDB{db, dsn, ctx, tb, c, make(map[string]bool)} if len(dbtablenames) == 0 { if err := db.Select(&dbtablenames, "SELECT tablename "+