| func ExpectEqual(actual any, extra any, explain ...any) { |
| 9 | gomega.ExpectWithOffset(1, actual).To(gomega.Equal(extra), explain...) |
| 10 | } |
| 11 |
| 12 | // ExpectEqualValues expects the specified two are the same, it not strict about type |
| 13 | func ExpectEqualValues(actual any, extra any, explain ...any) { |
| 14 | gomega.ExpectWithOffset(1, actual).To(gomega.BeEquivalentTo(extra), explain...) |
| 15 | } |
| 16 |
| 17 | func ExpectEqualValuesWithOffset(offset int, actual any, extra any, explain ...any) { |
| 18 | gomega.ExpectWithOffset(1+offset, actual).To(gomega.BeEquivalentTo(extra), explain...) |
| 19 | } |
| 20 |
| 21 | // ExpectNotEqual expects the specified two are not the same, otherwise an exception raises |
| 22 | func ExpectNotEqual(actual any, extra any, explain ...any) { |
| 23 | gomega.ExpectWithOffset(1, actual).NotTo(gomega.Equal(extra), explain...) |
| 24 | } |
| 25 |
| 26 | func ExpectErrorWithOffset(offset int, err error, explain ...any) { |
| 27 | gomega.ExpectWithOffset(1+offset, err).To(gomega.HaveOccurred(), explain...) |
| 28 | } |
| 29 |
| 30 | // ExpectNoError checks if "err" is set, and if so, fails assertion while logging the error. |
| 31 | func ExpectNoError(err error, explain ...any) { |
| 32 | ExpectNoErrorWithOffset(1, err, explain...) |
| 33 | } |
| 34 |
| 35 | // ExpectNoErrorWithOffset checks if "err" is set, and if so, fails assertion while logging the error at "offset" levels above its caller |
| 36 | // (for example, for call chain f -> g -> ExpectNoErrorWithOffset(1, ...) error would be logged for "f"). |
| 37 | func ExpectNoErrorWithOffset(offset int, err error, explain ...any) { |
| 38 | gomega.ExpectWithOffset(1+offset, err).NotTo(gomega.HaveOccurred(), explain...) |
| 39 | } |
| 40 |
| 41 | func ExpectContainSubstring(actual, substr string, explain ...any) { |
| 42 | gomega.ExpectWithOffset(1, actual).To(gomega.ContainSubstring(substr), explain...) |
| 43 | } |
| 44 |
| 45 | func ExpectContainElements(actual any, extra any, explain ...any) { |
| 46 | gomega.ExpectWithOffset(1, actual).To(gomega.ContainElements(extra), explain...) |
| 47 | } |
| 48 |
| 49 | func ExpectNotContainElements(actual any, extra any, explain ...any) { |
| 50 | gomega.ExpectWithOffset(1, actual).NotTo(gomega.ContainElements(extra), explain...) |
| 51 | } |
| 52 |
| 53 | func ExpectTrue(actual any, explain ...any) { |
| 54 | gomega.ExpectWithOffset(1, actual).Should(gomega.BeTrue(), explain...) |
| 55 | } |
| 56 |
| 57 | func ExpectTrueWithOffset(offset int, actual any, explain ...any) { |
| 58 | gomega.ExpectWithOffset(1+offset, actual).Should(gomega.BeTrue(), explain...) |
| 59 | } |