Пример #1
0
			err := realConn.Close()
			Ω(err).ShouldNot(HaveOccurred())

			postgresRunner.DropTestDB()
		})

		It("does not EXPLAIN the query", func() {
			rows, err := explainConn.Query("SELECT $1::int", 1)
			Ω(err).ShouldNot(HaveOccurred())

			err = rows.Close()
			Ω(err).ShouldNot(HaveOccurred())

			Ω(underlyingConn.QueryCallCount()).Should(Equal(1))

			query, args := underlyingConn.QueryArgsForCall(0)
			Ω(query).Should(Equal("SELECT $1::int"))
			Ω(args).Should(Equal(varargs(1)))
		})
	})

	Context("when the query takes more time than the timeout", func() {
		var realConn *sql.DB

		BeforeEach(func() {
			postgresRunner.CreateTestDB()
			realConn = postgresRunner.Open()
			underlyingConn.QueryStub = func(query string, args ...interface{}) (*sql.Rows, error) {
				if !strings.HasPrefix(query, "EXPLAIN") {
					time.Sleep(120 * time.Millisecond)
				}