Skip to content

Commit e22aedd

Browse files
committed
Tweaks and improvements - Fixes stretchr#154
1 parent 3b361f7 commit e22aedd

File tree

6 files changed

+19
-15
lines changed

6 files changed

+19
-15
lines changed

assert/assertions.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,12 @@ func ObjectsAreEqual(expected, actual interface{}) bool {
3636
return true
3737
}
3838

39-
// Last ditch effort
40-
if fmt.Sprintf("%#v", expected) == fmt.Sprintf("%#v", actual) {
41-
return true
42-
}
43-
4439
return false
4540

4641
}
4742

43+
// ObjectsAreEqualValues gets whether two objects are equal, or if their
44+
// values are equal.
4845
func ObjectsAreEqualValues(expected, actual interface{}) bool {
4946
if ObjectsAreEqual(expected, actual) {
5047
return true

assert/doc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// A set of comprehensive testing tools for use with the normal Go testing system.
1+
// Package assert provides a set of comprehensive testing tools for use with the normal Go testing system.
22
//
33
// Example Usage
44
//

assert/forward_assertions.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@ package assert
22

33
import "time"
44

5+
// Assertions provides assertion methods around the
6+
// TestingT interface.
57
type Assertions struct {
68
t TestingT
79
}
810

11+
// New makes a new Assertions object for the specified TestingT.
912
func New(t TestingT) *Assertions {
1013
return &Assertions{
1114
t: t,
@@ -85,7 +88,7 @@ func (a *Assertions) Empty(object interface{}, msgAndArgs ...interface{}) bool {
8588
return Empty(a.t, object, msgAndArgs...)
8689
}
8790

88-
// Empty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or a
91+
// NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or a
8992
// slice with len == 0.
9093
//
9194
// if assert.NotEmpty(obj) {
@@ -152,7 +155,7 @@ func (a *Assertions) NotContains(s, contains interface{}, msgAndArgs ...interfac
152155
return NotContains(a.t, s, contains, msgAndArgs...)
153156
}
154157

155-
// Uses a Comparison to assert a complex condition.
158+
// Condition uses a Comparison to assert a complex condition.
156159
func (a *Assertions) Condition(comp Comparison, msgAndArgs ...interface{}) bool {
157160
return Condition(a.t, comp, msgAndArgs...)
158161
}

assert/forward_assertions_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ func TestNoErrorWrapper(t *testing.T) {
264264
mockAssert := New(new(testing.T))
265265

266266
// start with a nil error
267-
var err error = nil
267+
var err error
268268

269269
assert.True(mockAssert.NoError(err), "NoError should return True for nil arg")
270270

@@ -280,7 +280,7 @@ func TestErrorWrapper(t *testing.T) {
280280
mockAssert := New(new(testing.T))
281281

282282
// start with a nil error
283-
var err error = nil
283+
var err error
284284

285285
assert.False(mockAssert.Error(err), "Error should return False for nil arg")
286286

assert/http_assertions.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ func HTTPError(t TestingT, handler http.HandlerFunc, mode, url string, values ur
5959
return code >= http.StatusBadRequest
6060
}
6161

62-
// HttpBody is a helper that returns HTTP body of the response. It returns
62+
// HTTPBody is a helper that returns HTTP body of the response. It returns
6363
// empty string if building a new request fails.
64-
func HttpBody(handler http.HandlerFunc, mode, url string, values url.Values) string {
64+
func HTTPBody(handler http.HandlerFunc, mode, url string, values url.Values) string {
6565
w := httptest.NewRecorder()
6666
req, err := http.NewRequest(mode, url+"?"+values.Encode(), nil)
6767
if err != nil {
@@ -78,7 +78,7 @@ func HttpBody(handler http.HandlerFunc, mode, url string, values url.Values) str
7878
//
7979
// Returns whether the assertion was successful (true) or not (false).
8080
func HTTPBodyContains(t TestingT, handler http.HandlerFunc, mode, url string, values url.Values, str interface{}) bool {
81-
body := HttpBody(handler, mode, url, values)
81+
body := HTTPBody(handler, mode, url, values)
8282

8383
contains := strings.Contains(body, fmt.Sprint(str))
8484
if !contains {
@@ -95,7 +95,7 @@ func HTTPBodyContains(t TestingT, handler http.HandlerFunc, mode, url string, va
9595
//
9696
// Returns whether the assertion was successful (true) or not (false).
9797
func HTTPBodyNotContains(t TestingT, handler http.HandlerFunc, mode, url string, values url.Values, str interface{}) bool {
98-
body := HttpBody(handler, mode, url, values)
98+
body := HTTPBody(handler, mode, url, values)
9999

100100
contains := strings.Contains(body, fmt.Sprint(str))
101101
if contains {

doc.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// A set of packages that provide many tools for testifying that your code will behave as you intend.
1+
// Package testify is a set of packages that provide many tools for testifying that your code will behave as you intend.
22
//
33
// testify contains the following packages:
44
//
@@ -11,8 +11,12 @@
1111
// The suite package provides a basic structure for using structs as testing suites, and methods on those structs as tests. It includes setup/teardown functionality in the way of interfaces.
1212
package testify
1313

14+
// blank imports help docs.
1415
import (
16+
// assert package
1517
_ "github.com/stretchr/testify/assert"
18+
// http package
1619
_ "github.com/stretchr/testify/http"
20+
// mock package
1721
_ "github.com/stretchr/testify/mock"
1822
)

0 commit comments

Comments
 (0)