コード例 #1
0
ファイル: http_test.go プロジェクト: jackc/tpr
// Empty all data in the entire database
func empty(pool *pgx.ConnPool) error {
	tables := []string{"feeds", "items", "password_resets", "sessions", "subscriptions", "unread_items", "users"}
	for _, table := range tables {
		_, err := pool.Exec(fmt.Sprintf("delete from %s", table))
		if err != nil {
			return err
		}
	}
	return nil
}
コード例 #2
0
ファイル: stress_test.go プロジェクト: segmentio/pgx
func setupStressDB(t *testing.T, pool *pgx.ConnPool) {
	_, err := pool.Exec(`
		drop table if exists widgets;
		create table widgets(
			id serial primary key,
			name varchar not null,
			description text,
			creation_time timestamptz
		);
`)
	if err != nil {
		t.Fatal(err)
	}
}
コード例 #3
0
ファイル: stress_test.go プロジェクト: segmentio/pgx
func notify(pool *pgx.ConnPool, actionNum int) error {
	_, err := pool.Exec("notify stress")
	return err
}
コード例 #4
0
ファイル: que_test.go プロジェクト: maheshbale/que-go
func truncateAndClose(pool *pgx.ConnPool) {
	if _, err := pool.Exec("TRUNCATE TABLE que_jobs"); err != nil {
		panic(err)
	}
	pool.Close()
}