ginkgo icon indicating copy to clipboard operation
ginkgo copied to clipboard

feature proposal: WhenTable

Open maguro opened this issue 6 months ago • 2 comments

I very much would like DescribeTable to behave like a container, e.g.

DescribeTable("a k8s heartbeat request arrives",
	func(endStream bool) {
		It("is ignored when processing downstream headers", func() {
			status := filter.DecodeHeaders(reqH, endStream)
			Ω(status).Should(Equal(api.Continue))
		})

		It("is ignored when processing downstream data", func() {
			buffer := mockenvoy.NewBufferInstance(GinkgoT())

			status := filter.DecodeData(buffer, endStream)
			Ω(status).Should(Equal(api.Continue))
		})
	},
	Entry("stream is still live", false),
	Entry("stream has ended", true),
)

But that won't work for obvious reasons. I proposed we add WhenTable:

WhenTable("a k8s heartbeat request arrives",
	func(endStream bool) {
		It("is ignored when processing downstream headers", func() {
			status := filter.DecodeHeaders(reqH, endStream)
			Ω(status).Should(Equal(api.Continue))
		})

		It("is ignored when processing downstream data", func() {
			buffer := mockenvoy.NewBufferInstance(GinkgoT())

			status := filter.DecodeData(buffer, endStream)
			Ω(status).Should(Equal(api.Continue))
		})
	},
	Entry("stream is still live", false),
	Entry("stream has ended", true),
)

maguro avatar Dec 23 '23 00:12 maguro

Hi @maguro. Have you thought about dynamically generating specs? It’s something that you could do right now without waiting for a feature to be implemented.

https://onsi.github.io/ginkgo/#dynamically-generating-specs

blgm avatar Dec 24 '23 18:12 blgm

hey @maguro this sounds like a great idea. i took a look and it was actually relatively easy to implement. I've added DescribeTableSubtree - please take a look at the latest commit on master and the docs here and let me know what you think. I'd love it if you could give it a try and make sure it works for you before I cut a release.

onsi avatar Dec 26 '23 21:12 onsi