Example #1
0
func closeDB(t *testing.T, db *sql.DB, shouldStmtCount, ignoreIfStmtCount int) {
	s := db.Driver().(*Driver).Stats
	err := db.Close()
	if err != nil {
		t.Fatalf("error closing DB: %v", err)
	}
	switch s.StmtCount {
	case shouldStmtCount:
		// all good
	case ignoreIfStmtCount:
		t.Logf("ignoring unexpected StmtCount of %v", ignoreIfStmtCount)
	default:
		t.Errorf("unexpected StmtCount: should=%v, is=%v", ignoreIfStmtCount, s.StmtCount)
	}
}