pulsarctl icon indicating copy to clipboard operation
pulsarctl copied to clipboard

Use gomega test the http request

Open nodece opened this issue 3 years ago • 0 comments

Enhancement

Both testify and gomega are test libraries, it can help developers use this to assert data on the test case, but the testify is not friendly on asynchronous assertions way, so I found gomega is a great library on this way, you can find this documentation here, a simple test so like:

    Eventually(func(g Gomega) {
        model, err := client.Find(1138)
        g.Expect(err).NotTo(HaveOccurred())
        g.Expect(model.Reticulate()).To(Succeed())
        g.Expect(model.IsReticulated()).To(BeTrue())
        g.Expect(model.Save()).To(Succeed())
    }).Should(Succeed())

We need this way to test the topic/namespace commands, and assert is simple.

nodece avatar Jan 05 '22 10:01 nodece