diff options
author | Matus Fabian <matfabia@cisco.com> | 2024-08-22 15:32:44 +0200 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2024-08-23 05:56:33 +0000 |
commit | 225e6f86a4fdc6ec00da4527e7697cd122b16783 (patch) | |
tree | c3d50fee56053971397b8710121a8e32f6b96c9d /extras | |
parent | c47d7ad72172e820b04455a1dbc555c33ce710d7 (diff) |
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 <matfabia@cisco.com>
Diffstat (limited to 'extras')
-rw-r--r-- | extras/hs-test/infra/hst_suite.go | 18 |
1 files 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() { |