Пример #1
0
	It("returns the return values from the underlying connection", func() {
		underlyingConn.PingReturns(errors.New("disaster"))

		err := explainConn.Ping()
		Ω(err).Should(MatchError("disaster"))
	})

	Context("when the query takes less 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) {
				return realConn.Query(query, args...)
			}
		})

		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()