From 2eca2b1976672aef09e63f0ab56329bc33a2fb5c Mon Sep 17 00:00:00 2001 From: Archit Agarwal Date: Sun, 3 Nov 2024 02:19:05 +0530 Subject: [PATCH 1/7] update documentation for the Error function in assert or require package #1609 --- assert/assertions.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/assert/assertions.go b/assert/assertions.go index 4e91332bb..295144d14 100644 --- a/assert/assertions.go +++ b/assert/assertions.go @@ -1591,10 +1591,8 @@ func NoError(t TestingT, err error, msgAndArgs ...interface{}) bool { // Error asserts that a function returned an error (i.e. not `nil`). // -// actualObj, err := SomeFunction() -// if assert.Error(t, err) { -// assert.Equal(t, expectedError, err) -// } +// actualObj, err := SomeFunction() +// assert.Error(t, err) func Error(t TestingT, err error, msgAndArgs ...interface{}) bool { if err == nil { if h, ok := t.(tHelper); ok { From d27af4e3f5556bca53d8f401be6324776e64db22 Mon Sep 17 00:00:00 2001 From: Archit Agarwal Date: Sun, 3 Nov 2024 02:51:16 +0530 Subject: [PATCH 2/7] update documentation for auto require package --- assert/assertion_format.go | 6 ++---- assert/assertion_forward.go | 12 ++++-------- require/require.go | 12 ++++-------- require/require_forward.go | 12 ++++-------- 4 files changed, 14 insertions(+), 28 deletions(-) diff --git a/assert/assertion_format.go b/assert/assertion_format.go index 190634165..ebcbae58a 100644 --- a/assert/assertion_format.go +++ b/assert/assertion_format.go @@ -117,10 +117,8 @@ func EqualValuesf(t TestingT, expected interface{}, actual interface{}, msg stri // Errorf asserts that a function returned an error (i.e. not `nil`). // -// actualObj, err := SomeFunction() -// if assert.Errorf(t, err, "error message %s", "formatted") { -// assert.Equal(t, expectedErrorf, err) -// } +// actualObj, err := SomeFunction() +// assert.Errorf(t, err, "error message %s", "formatted") func Errorf(t TestingT, err error, msg string, args ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() diff --git a/assert/assertion_forward.go b/assert/assertion_forward.go index 21629087b..6222d1269 100644 --- a/assert/assertion_forward.go +++ b/assert/assertion_forward.go @@ -224,10 +224,8 @@ func (a *Assertions) Equalf(expected interface{}, actual interface{}, msg string // Error asserts that a function returned an error (i.e. not `nil`). // -// actualObj, err := SomeFunction() -// if a.Error(err) { -// assert.Equal(t, expectedError, err) -// } +// actualObj, err := SomeFunction() +// a.Error(err) func (a *Assertions) Error(err error, msgAndArgs ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -297,10 +295,8 @@ func (a *Assertions) ErrorIsf(err error, target error, msg string, args ...inter // Errorf asserts that a function returned an error (i.e. not `nil`). // -// actualObj, err := SomeFunction() -// if a.Errorf(err, "error message %s", "formatted") { -// assert.Equal(t, expectedErrorf, err) -// } +// actualObj, err := SomeFunction() +// a.Errorf(err, "error message %s", "formatted") func (a *Assertions) Errorf(err error, msg string, args ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() diff --git a/require/require.go b/require/require.go index d8921950d..5cc14fa07 100644 --- a/require/require.go +++ b/require/require.go @@ -279,10 +279,8 @@ func Equalf(t TestingT, expected interface{}, actual interface{}, msg string, ar // Error asserts that a function returned an error (i.e. not `nil`). // -// actualObj, err := SomeFunction() -// if require.Error(t, err) { -// require.Equal(t, expectedError, err) -// } +// actualObj, err := SomeFunction() +// require.Error(t, err) func Error(t TestingT, err error, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -373,10 +371,8 @@ func ErrorIsf(t TestingT, err error, target error, msg string, args ...interface // Errorf asserts that a function returned an error (i.e. not `nil`). // -// actualObj, err := SomeFunction() -// if require.Errorf(t, err, "error message %s", "formatted") { -// require.Equal(t, expectedErrorf, err) -// } +// actualObj, err := SomeFunction() +// require.Errorf(t, err, "error message %s", "formatted") func Errorf(t TestingT, err error, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() diff --git a/require/require_forward.go b/require/require_forward.go index 1bd87304f..096904ba3 100644 --- a/require/require_forward.go +++ b/require/require_forward.go @@ -225,10 +225,8 @@ func (a *Assertions) Equalf(expected interface{}, actual interface{}, msg string // Error asserts that a function returned an error (i.e. not `nil`). // -// actualObj, err := SomeFunction() -// if a.Error(err) { -// assert.Equal(t, expectedError, err) -// } +// actualObj, err := SomeFunction() +// a.Error(err) func (a *Assertions) Error(err error, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -298,10 +296,8 @@ func (a *Assertions) ErrorIsf(err error, target error, msg string, args ...inter // Errorf asserts that a function returned an error (i.e. not `nil`). // -// actualObj, err := SomeFunction() -// if a.Errorf(err, "error message %s", "formatted") { -// assert.Equal(t, expectedErrorf, err) -// } +// actualObj, err := SomeFunction() +// a.Errorf(err, "error message %s", "formatted") func (a *Assertions) Errorf(err error, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() From d5cd75acec87ebc41af613a3cc2a438d26a9f519 Mon Sep 17 00:00:00 2001 From: Archit Agarwal Date: Tue, 22 Apr 2025 23:33:01 +0530 Subject: [PATCH 3/7] update documentation of assert package to mention that all function return a bool value --- assert/doc.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assert/doc.go b/assert/doc.go index 4953981d3..925cc69d1 100644 --- a/assert/doc.go +++ b/assert/doc.go @@ -1,5 +1,5 @@ // Package assert provides a set of comprehensive testing tools for use with the normal Go testing system. -// +// All functions in this package return a bool value indicating whether the test has passed. // # Example Usage // // The following is a complete example using assert in a standard test function: From e32ceae4ea31a90929ef3585f102451cb26661e3 Mon Sep 17 00:00:00 2001 From: Archit Agarwal Date: Tue, 29 Apr 2025 17:08:34 +0530 Subject: [PATCH 4/7] Update assert/doc.go Co-authored-by: ccoVeille <3875889+ccoVeille@users.noreply.github.com> --- assert/doc.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/assert/doc.go b/assert/doc.go index 925cc69d1..b39ebdbfd 100644 --- a/assert/doc.go +++ b/assert/doc.go @@ -1,6 +1,9 @@ // Package assert provides a set of comprehensive testing tools for use with the normal Go testing system. +// +// # Note // All functions in this package return a bool value indicating whether the test has passed. -// # Example Usage + // + // # Example Usage // // The following is a complete example using assert in a standard test function: // From 992db2b883ecca754085f89e543c66e38edbf97c Mon Sep 17 00:00:00 2001 From: Archit Agarwal Date: Tue, 29 Apr 2025 17:10:00 +0530 Subject: [PATCH 5/7] upadte doc --- assert/doc.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/assert/doc.go b/assert/doc.go index b39ebdbfd..f0f186a65 100644 --- a/assert/doc.go +++ b/assert/doc.go @@ -2,8 +2,8 @@ // // # Note // All functions in this package return a bool value indicating whether the test has passed. - // - // # Example Usage +// +// # Example Usage // // The following is a complete example using assert in a standard test function: // From 0c9a9e02f82c4835d66d16781b23ba6e93d94bd7 Mon Sep 17 00:00:00 2001 From: Archit Agarwal Date: Fri, 2 May 2025 13:01:29 +0530 Subject: [PATCH 6/7] Update assert/doc.go Co-authored-by: ccoVeille <3875889+ccoVeille@users.noreply.github.com> --- assert/doc.go | 1 + 1 file changed, 1 insertion(+) diff --git a/assert/doc.go b/assert/doc.go index f0f186a65..6abab4a49 100644 --- a/assert/doc.go +++ b/assert/doc.go @@ -1,6 +1,7 @@ // Package assert provides a set of comprehensive testing tools for use with the normal Go testing system. // // # Note +// // All functions in this package return a bool value indicating whether the test has passed. // // # Example Usage From d0c350a872fb8dfa57792280e64d3bc27be90043 Mon Sep 17 00:00:00 2001 From: Archit Agarwal Date: Wed, 7 May 2025 17:25:57 +0530 Subject: [PATCH 7/7] Update assert/doc.go Co-authored-by: Bracken --- assert/doc.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assert/doc.go b/assert/doc.go index 6abab4a49..a0b953aa5 100644 --- a/assert/doc.go +++ b/assert/doc.go @@ -2,7 +2,7 @@ // // # Note // -// All functions in this package return a bool value indicating whether the test has passed. +// All functions in this package return a bool value indicating whether the assertion has passed. // // # Example Usage //