Skip to content

Commit 21ba5d2

Browse files
authored
Merge branch 'master' into uintptr
2 parents f7b49d3 + 7df1a82 commit 21ba5d2

28 files changed

+2257
-1223
lines changed

.github/workflows/main.yml

+23-4
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,33 @@ jobs:
66
runs-on: ubuntu-latest
77
strategy:
88
matrix:
9-
go_version: ["1.18.1", "1.17.6", "1.16.5"]
9+
go_version:
10+
- "1.20"
11+
- "1.21"
1012
steps:
11-
- uses: actions/checkout@v3
13+
- uses: actions/checkout@v4
1214
- name: Setup Go
13-
uses: actions/setup-go@v3.2.0
15+
uses: actions/setup-go@v4.1.0
1416
with:
1517
go-version: ${{ matrix.go_version }}
16-
- run: ./.ci.gogenerate.sh
18+
- run: ./.ci.gogenerate.sh
1719
- run: ./.ci.gofmt.sh
1820
- run: ./.ci.govet.sh
1921
- run: go test -v -race ./...
22+
test:
23+
runs-on: ubuntu-latest
24+
strategy:
25+
matrix:
26+
go_version:
27+
- "1.17"
28+
- "1.18"
29+
- "1.19"
30+
- "1.20"
31+
- "1.21"
32+
steps:
33+
- uses: actions/checkout@v4
34+
- name: Setup Go
35+
uses: actions/[email protected]
36+
with:
37+
go-version: ${{ matrix.go_version }}
38+
- run: go test -v -race ./...

.github/workflows/release.yml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Create release from new tag
2+
3+
# this flow will be run only when new tags are pushed that match our pattern
4+
on:
5+
push:
6+
tags:
7+
- "v[0-9]+.[0-9]+.[0-9]+"
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
18+
- name: Create GitHub release from tag
19+
uses: softprops/action-gh-release@v1

MAINTAINERS.md

-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@ pull requests.
55

66
* @glesica
77
* @boyan-soubachov
8-
* @mvdkleijn
98

README.md

+21-19
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ Features include:
1616
Get started:
1717

1818
* Install testify with [one line of code](#installation), or [update it with another](#staying-up-to-date)
19-
* For an introduction to writing test code in Go, see http://golang.org/doc/code.html#Testing
20-
* Check out the API Documentation http://godoc.org/github.com/stretchr/testify
21-
* To make your testing life easier, check out our other project, [gorc](http://github.com/stretchr/gorc)
22-
* A little about [Test-Driven Development (TDD)](http://en.wikipedia.org/wiki/Test-driven_development)
19+
* For an introduction to writing test code in Go, see https://go.dev/doc/code#Testing
20+
* Check out the API Documentation https://pkg.go.dev/github.com/stretchr/testify
21+
* To make your testing life easier, check out our other project, [gorc](https://github.com/stretchr/gorc)
22+
* A little about [Test-Driven Development (TDD)](https://en.wikipedia.org/wiki/Test-driven_development)
2323

2424

2525

26-
[`assert`](http://godoc.org/github.com/stretchr/testify/assert "API documentation") package
26+
[`assert`](https://pkg.go.dev/github.com/stretchr/testify/assert "API documentation") package
2727
-------------------------------------------------------------------------------------------
2828

2929
The `assert` package provides some helpful methods that allow you to write better test code in Go.
@@ -100,19 +100,21 @@ func TestSomething(t *testing.T) {
100100
}
101101
```
102102

103-
[`require`](http://godoc.org/github.com/stretchr/testify/require "API documentation") package
103+
[`require`](https://pkg.go.dev/github.com/stretchr/testify/require "API documentation") package
104104
---------------------------------------------------------------------------------------------
105105

106106
The `require` package provides same global functions as the `assert` package, but instead of returning a boolean result they terminate current test.
107+
These functions must be called from the goroutine running the test or benchmark function, not from other goroutines created during the test.
108+
Otherwise race conditions may occur.
107109

108-
See [t.FailNow](http://golang.org/pkg/testing/#T.FailNow) for details.
110+
See [t.FailNow](https://pkg.go.dev/testing#T.FailNow) for details.
109111

110-
[`mock`](http://godoc.org/github.com/stretchr/testify/mock "API documentation") package
112+
[`mock`](https://pkg.go.dev/github.com/stretchr/testify/mock "API documentation") package
111113
----------------------------------------------------------------------------------------
112114

113115
The `mock` package provides a mechanism for easily writing mock objects that can be used in place of real objects when writing test code.
114116

115-
An example test function that tests a piece of code that relies on an external object `testObj`, can setup expectations (testify) and assert that they indeed happened:
117+
An example test function that tests a piece of code that relies on an external object `testObj`, can set up expectations (testify) and assert that they indeed happened:
116118

117119
```go
118120
package yours
@@ -157,7 +159,7 @@ func TestSomething(t *testing.T) {
157159
// create an instance of our test object
158160
testObj := new(MyMockedObject)
159161

160-
// setup expectations
162+
// set up expectations
161163
testObj.On("DoSomething", 123).Return(true, nil)
162164

163165
// call the code we are testing
@@ -179,7 +181,7 @@ func TestSomethingWithPlaceholder(t *testing.T) {
179181
// create an instance of our test object
180182
testObj := new(MyMockedObject)
181183

182-
// setup expectations with a placeholder in the argument list
184+
// set up expectations with a placeholder in the argument list
183185
testObj.On("DoSomething", mock.Anything).Return(true, nil)
184186

185187
// call the code we are testing
@@ -198,7 +200,7 @@ func TestSomethingElse2(t *testing.T) {
198200
// create an instance of our test object
199201
testObj := new(MyMockedObject)
200202

201-
// setup expectations with a placeholder in the argument list
203+
// set up expectations with a placeholder in the argument list
202204
mockCall := testObj.On("DoSomething", mock.Anything).Return(true, nil)
203205

204206
// call the code we are testing
@@ -217,14 +219,14 @@ func TestSomethingElse2(t *testing.T) {
217219
}
218220
```
219221

220-
For more information on how to write mock code, check out the [API documentation for the `mock` package](http://godoc.org/github.com/stretchr/testify/mock).
222+
For more information on how to write mock code, check out the [API documentation for the `mock` package](https://pkg.go.dev/github.com/stretchr/testify/mock).
221223

222-
You can use the [mockery tool](http://github.com/vektra/mockery) to autogenerate the mock code against an interface as well, making using mocks much quicker.
224+
You can use the [mockery tool](https://vektra.github.io/mockery/latest/) to autogenerate the mock code against an interface as well, making using mocks much quicker.
223225

224-
[`suite`](http://godoc.org/github.com/stretchr/testify/suite "API documentation") package
226+
[`suite`](https://pkg.go.dev/github.com/stretchr/testify/suite "API documentation") package
225227
-----------------------------------------------------------------------------------------
226228

227-
The `suite` package provides functionality that you might be used to from more common object oriented languages. With it, you can build a testing suite as a struct, build setup/teardown methods and testing methods on your struct, and run them with 'go test' as per normal.
229+
The `suite` package provides functionality that you might be used to from more common object-oriented languages. With it, you can build a testing suite as a struct, build setup/teardown methods and testing methods on your struct, and run them with 'go test' as per normal.
228230

229231
An example suite is shown below:
230232

@@ -265,7 +267,7 @@ func TestExampleTestSuite(t *testing.T) {
265267

266268
For a more complete example, using all of the functionality provided by the suite package, look at our [example testing suite](https://github.com/stretchr/testify/blob/master/suite/suite_test.go)
267269

268-
For more information on writing suites, check out the [API documentation for the `suite` package](http://godoc.org/github.com/stretchr/testify/suite).
270+
For more information on writing suites, check out the [API documentation for the `suite` package](https://pkg.go.dev/github.com/stretchr/testify/suite).
269271

270272
`Suite` object has assertion methods:
271273

@@ -348,7 +350,7 @@ To update Testify to the latest version, use `go get -u github.com/stretchr/test
348350
Supported go versions
349351
==================
350352

351-
We currently support the most recent major Go versions from 1.13 onward.
353+
We currently support the most recent major Go versions from 1.19 onward.
352354

353355
------
354356

@@ -359,7 +361,7 @@ Please feel free to submit issues, fork the repository and send pull requests!
359361

360362
When submitting an issue, we ask that you please include a complete test function that demonstrates the issue. Extra credit for those using Testify to write the test code that demonstrates it.
361363

362-
Code generation is used. Look for `CODE GENERATED AUTOMATICALLY` at the top of some files. Run `go generate ./...` to update generated files.
364+
Code generation is used. [Look for `Code generated with`](https://github.com/search?q=repo%3Astretchr%2Ftestify%20%22Code%20generated%20with%22&type=code) at the top of some files. Run `go generate ./...` to update generated files.
363365

364366
We also chat on the [Gophers Slack](https://gophers.slack.com) group in the `#testify` and `#testify-dev` channels.
365367

_codegen/main.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -297,10 +297,8 @@ func (f *testFunc) CommentWithoutT(receiver string) string {
297297
return strings.Replace(f.Comment(), search, replace, -1)
298298
}
299299

300-
var headerTemplate = `/*
301-
* CODE GENERATED AUTOMATICALLY WITH github.com/stretchr/testify/_codegen
302-
* THIS FILE MUST NOT BE EDITED BY HAND
303-
*/
300+
// Standard header https://go.dev/s/generatedcode.
301+
var headerTemplate = `// Code generated with github.com/stretchr/testify/_codegen; DO NOT EDIT.
304302
305303
package {{.Name}}
306304

assert/assertion_compare.go

+21-21
Original file line numberDiff line numberDiff line change
@@ -310,11 +310,11 @@ func compare(obj1, obj2 interface{}, kind reflect.Kind) (CompareType, bool) {
310310
case reflect.Struct:
311311
{
312312
// All structs enter here. We're not interested in most types.
313-
if !canConvert(obj1Value, timeType) {
313+
if !obj1Value.CanConvert(timeType) {
314314
break
315315
}
316316

317-
// time.Time can compared!
317+
// time.Time can be compared!
318318
timeObj1, ok := obj1.(time.Time)
319319
if !ok {
320320
timeObj1 = obj1Value.Convert(timeType).Interface().(time.Time)
@@ -330,7 +330,7 @@ func compare(obj1, obj2 interface{}, kind reflect.Kind) (CompareType, bool) {
330330
case reflect.Slice:
331331
{
332332
// We only care about the []byte type.
333-
if !canConvert(obj1Value, bytesType) {
333+
if !obj1Value.CanConvert(bytesType) {
334334
break
335335
}
336336

@@ -374,9 +374,9 @@ func compare(obj1, obj2 interface{}, kind reflect.Kind) (CompareType, bool) {
374374

375375
// Greater asserts that the first element is greater than the second
376376
//
377-
// assert.Greater(t, 2, 1)
378-
// assert.Greater(t, float64(2), float64(1))
379-
// assert.Greater(t, "b", "a")
377+
// assert.Greater(t, 2, 1)
378+
// assert.Greater(t, float64(2), float64(1))
379+
// assert.Greater(t, "b", "a")
380380
func Greater(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool {
381381
if h, ok := t.(tHelper); ok {
382382
h.Helper()
@@ -386,10 +386,10 @@ func Greater(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface
386386

387387
// GreaterOrEqual asserts that the first element is greater than or equal to the second
388388
//
389-
// assert.GreaterOrEqual(t, 2, 1)
390-
// assert.GreaterOrEqual(t, 2, 2)
391-
// assert.GreaterOrEqual(t, "b", "a")
392-
// assert.GreaterOrEqual(t, "b", "b")
389+
// assert.GreaterOrEqual(t, 2, 1)
390+
// assert.GreaterOrEqual(t, 2, 2)
391+
// assert.GreaterOrEqual(t, "b", "a")
392+
// assert.GreaterOrEqual(t, "b", "b")
393393
func GreaterOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool {
394394
if h, ok := t.(tHelper); ok {
395395
h.Helper()
@@ -399,9 +399,9 @@ func GreaterOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...in
399399

400400
// Less asserts that the first element is less than the second
401401
//
402-
// assert.Less(t, 1, 2)
403-
// assert.Less(t, float64(1), float64(2))
404-
// assert.Less(t, "a", "b")
402+
// assert.Less(t, 1, 2)
403+
// assert.Less(t, float64(1), float64(2))
404+
// assert.Less(t, "a", "b")
405405
func Less(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool {
406406
if h, ok := t.(tHelper); ok {
407407
h.Helper()
@@ -411,10 +411,10 @@ func Less(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{})
411411

412412
// LessOrEqual asserts that the first element is less than or equal to the second
413413
//
414-
// assert.LessOrEqual(t, 1, 2)
415-
// assert.LessOrEqual(t, 2, 2)
416-
// assert.LessOrEqual(t, "a", "b")
417-
// assert.LessOrEqual(t, "b", "b")
414+
// assert.LessOrEqual(t, 1, 2)
415+
// assert.LessOrEqual(t, 2, 2)
416+
// assert.LessOrEqual(t, "a", "b")
417+
// assert.LessOrEqual(t, "b", "b")
418418
func LessOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool {
419419
if h, ok := t.(tHelper); ok {
420420
h.Helper()
@@ -424,8 +424,8 @@ func LessOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...inter
424424

425425
// Positive asserts that the specified element is positive
426426
//
427-
// assert.Positive(t, 1)
428-
// assert.Positive(t, 1.23)
427+
// assert.Positive(t, 1)
428+
// assert.Positive(t, 1.23)
429429
func Positive(t TestingT, e interface{}, msgAndArgs ...interface{}) bool {
430430
if h, ok := t.(tHelper); ok {
431431
h.Helper()
@@ -436,8 +436,8 @@ func Positive(t TestingT, e interface{}, msgAndArgs ...interface{}) bool {
436436

437437
// Negative asserts that the specified element is negative
438438
//
439-
// assert.Negative(t, -1)
440-
// assert.Negative(t, -1.23)
439+
// assert.Negative(t, -1)
440+
// assert.Negative(t, -1.23)
441441
func Negative(t TestingT, e interface{}, msgAndArgs ...interface{}) bool {
442442
if h, ok := t.(tHelper); ok {
443443
h.Helper()

assert/assertion_compare_can_convert.go

-16
This file was deleted.

0 commit comments

Comments
 (0)