AfterEach(func() { 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") {
} }) AfterEach(func() { err := realConn.Close() Expect(err).NotTo(HaveOccurred()) }) It("does not EXPLAIN the query", func() { rows, err := explainConn.Query("SELECT $1::int", 1) Expect(err).NotTo(HaveOccurred()) err = rows.Close() Expect(err).NotTo(HaveOccurred()) Expect(underlyingConn.QueryCallCount()).To(Equal(1)) query, args := underlyingConn.QueryArgsForCall(0) Expect(query).To(Equal("SELECT $1::int")) Expect(args).To(Equal(varargs(1))) }) }) Context("when the query takes more time than the timeout", func() { var realConn *sql.DB BeforeEach(func() { postgresRunner.Truncate() realConn = postgresRunner.Open() underlyingConn.QueryStub = func(query string, args ...interface{}) (*sql.Rows, error) {