From 225e6f86a4fdc6ec00da4527e7697cd122b16783 Mon Sep 17 00:00:00 2001 From: Matus Fabian Date: Thu, 22 Aug 2024 15:32:44 +0200 Subject: hs-test: assert improvement Use ExpectWithOffset so Ginkgo's output point to the line in your test. Type: test Change-Id: Icb32c5be683f935a5e86f25c2ec5a6dfad2ec1ea Signed-off-by: Matus Fabian --- extras/hs-test/infra/hst_suite.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/extras/hs-test/infra/hst_suite.go b/extras/hs-test/infra/hst_suite.go index 271ef99f249..21e4f098d9a 100644 --- a/extras/hs-test/infra/hst_suite.go +++ b/extras/hs-test/infra/hst_suite.go @@ -225,39 +225,39 @@ func (s *HstSuite) HstFail() { } func (s *HstSuite) AssertNil(object interface{}, msgAndArgs ...interface{}) { - Expect(object).To(BeNil(), msgAndArgs...) + ExpectWithOffset(2, object).To(BeNil(), msgAndArgs...) } func (s *HstSuite) AssertNotNil(object interface{}, msgAndArgs ...interface{}) { - Expect(object).ToNot(BeNil(), msgAndArgs...) + ExpectWithOffset(2, object).ToNot(BeNil(), msgAndArgs...) } func (s *HstSuite) AssertEqual(expected, actual interface{}, msgAndArgs ...interface{}) { - Expect(actual).To(Equal(expected), msgAndArgs...) + ExpectWithOffset(2, actual).To(Equal(expected), msgAndArgs...) } func (s *HstSuite) AssertNotEqual(expected, actual interface{}, msgAndArgs ...interface{}) { - Expect(actual).ToNot(Equal(expected), msgAndArgs...) + ExpectWithOffset(2, actual).ToNot(Equal(expected), msgAndArgs...) } func (s *HstSuite) AssertContains(testString, contains interface{}, msgAndArgs ...interface{}) { - Expect(testString).To(ContainSubstring(fmt.Sprint(contains)), msgAndArgs...) + ExpectWithOffset(2, testString).To(ContainSubstring(fmt.Sprint(contains)), msgAndArgs...) } func (s *HstSuite) AssertNotContains(testString, contains interface{}, msgAndArgs ...interface{}) { - Expect(testString).ToNot(ContainSubstring(fmt.Sprint(contains)), msgAndArgs...) + ExpectWithOffset(2, testString).ToNot(ContainSubstring(fmt.Sprint(contains)), msgAndArgs...) } func (s *HstSuite) AssertEmpty(object interface{}, msgAndArgs ...interface{}) { - Expect(object).To(BeEmpty(), msgAndArgs...) + ExpectWithOffset(2, object).To(BeEmpty(), msgAndArgs...) } func (s *HstSuite) AssertNotEmpty(object interface{}, msgAndArgs ...interface{}) { - Expect(object).ToNot(BeEmpty(), msgAndArgs...) + ExpectWithOffset(2, object).ToNot(BeEmpty(), msgAndArgs...) } func (s *HstSuite) AssertMatchError(actual, expected error, msgAndArgs ...interface{}) { - Expect(actual).To(MatchError(expected)) + ExpectWithOffset(2, actual).To(MatchError(expected)) } func (s *HstSuite) CreateLogger() { -- cgit 1.2.3-korg