Exemplo n.º 1
0
				err = rows.Close()
				Ω(err).ShouldNot(HaveOccurred())

				Expect(logger).To(gbytes.Say("Result"))
				Expect(logger).To(gbytes.Say("cost="))
				Expect(logger).To(gbytes.Say("SELECT"))
			})
		})

		Describe("QueryRow()", func() {
			It("EXPLAINs the query", func() {
				var i int
				err := explainConn.QueryRow("SELECT $1::int", 1).Scan(&i)
				Ω(err).ShouldNot(HaveOccurred())

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

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

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

			It("logs the output of the explain", func() {
				var i int
				err := explainConn.QueryRow("SELECT $1::int", 1).Scan(&i)
				Ω(err).ShouldNot(HaveOccurred())
Exemplo n.º 2
0
				err = rows.Close()
				Expect(err).NotTo(HaveOccurred())

				Expect(logger).To(gbytes.Say("Result"))
				Expect(logger).To(gbytes.Say("cost="))
				Expect(logger).To(gbytes.Say("SELECT"))
			})
		})

		Describe("QueryRow()", func() {
			It("EXPLAINs the query", func() {
				var i int
				err := explainConn.QueryRow("SELECT $1::int", 1).Scan(&i)
				Expect(err).NotTo(HaveOccurred())

				Expect(underlyingConn.QueryRowCallCount()).To(Equal(1))
				Expect(underlyingConn.QueryCallCount()).To(Equal(1))

				query, args := underlyingConn.QueryRowArgsForCall(0)
				Expect(query).To(Equal("SELECT $1::int"))
				Expect(args).To(Equal(varargs(1)))

				query, args = underlyingConn.QueryArgsForCall(0)
				Expect(query).To(Equal("EXPLAIN SELECT $1::int"))
				Expect(args).To(Equal(varargs(1)))
			})

			It("logs the output of the explain", func() {
				var i int
				err := explainConn.QueryRow("SELECT $1::int", 1).Scan(&i)
				Expect(err).NotTo(HaveOccurred())