Skip to content

Commit f19cdfc

Browse files
authored
Merge branch 'master' into patch-1
2 parents afd76b4 + 4ae48e9 commit f19cdfc

30 files changed

+2306
-1213
lines changed

.github/workflows/main.yml

+22-4
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,32 @@ 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.19"
11+
- "1.20"
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+
steps:
32+
- uses: actions/checkout@v4
33+
- name: Setup Go
34+
uses: actions/[email protected]
35+
with:
36+
go-version: ${{ matrix.go_version }}
37+
- 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

+20-18
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ 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-
* 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+
* A little about [Test-Driven Development (TDD)](https://en.wikipedia.org/wiki/Test-driven_development)
2222

2323

2424

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

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

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

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

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

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

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

114-
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:
116+
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:
115117

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

159-
// setup expectations
161+
// set up expectations
160162
testObj.On("DoSomething", 123).Return(true, nil)
161163

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

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

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

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

203205
// call the code we are testing
@@ -216,14 +218,14 @@ func TestSomethingElse2(t *testing.T) {
216218
}
217219
```
218220

219-
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).
221+
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).
220222

221-
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.
223+
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.
222224

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

226-
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.
228+
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.
227229

228230
An example suite is shown below:
229231

@@ -264,7 +266,7 @@ func TestExampleTestSuite(t *testing.T) {
264266

265267
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)
266268

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

269271
`Suite` object has assertion methods:
270272

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

350-
We currently support the most recent major Go versions from 1.13 onward.
352+
We currently support the most recent major Go versions from 1.19 onward.
351353

352354
------
353355

@@ -358,7 +360,7 @@ Please feel free to submit issues, fork the repository and send pull requests!
358360

359361
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.
360362

361-
Code generation is used. Look for `CODE GENERATED AUTOMATICALLY` at the top of some files. Run `go generate ./...` to update generated files.
363+
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.
362364

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

_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
@@ -308,11 +308,11 @@ func compare(obj1, obj2 interface{}, kind reflect.Kind) (CompareType, bool) {
308308
case reflect.Struct:
309309
{
310310
// All structs enter here. We're not interested in most types.
311-
if !canConvert(obj1Value, timeType) {
311+
if !obj1Value.CanConvert(timeType) {
312312
break
313313
}
314314

315-
// time.Time can compared!
315+
// time.Time can be compared!
316316
timeObj1, ok := obj1.(time.Time)
317317
if !ok {
318318
timeObj1 = obj1Value.Convert(timeType).Interface().(time.Time)
@@ -328,7 +328,7 @@ func compare(obj1, obj2 interface{}, kind reflect.Kind) (CompareType, bool) {
328328
case reflect.Slice:
329329
{
330330
// We only care about the []byte type.
331-
if !canConvert(obj1Value, bytesType) {
331+
if !obj1Value.CanConvert(bytesType) {
332332
break
333333
}
334334

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

353353
// Greater asserts that the first element is greater than the second
354354
//
355-
// assert.Greater(t, 2, 1)
356-
// assert.Greater(t, float64(2), float64(1))
357-
// assert.Greater(t, "b", "a")
355+
// assert.Greater(t, 2, 1)
356+
// assert.Greater(t, float64(2), float64(1))
357+
// assert.Greater(t, "b", "a")
358358
func Greater(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool {
359359
if h, ok := t.(tHelper); ok {
360360
h.Helper()
@@ -364,10 +364,10 @@ func Greater(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface
364364

365365
// GreaterOrEqual asserts that the first element is greater than or equal to the second
366366
//
367-
// assert.GreaterOrEqual(t, 2, 1)
368-
// assert.GreaterOrEqual(t, 2, 2)
369-
// assert.GreaterOrEqual(t, "b", "a")
370-
// assert.GreaterOrEqual(t, "b", "b")
367+
// assert.GreaterOrEqual(t, 2, 1)
368+
// assert.GreaterOrEqual(t, 2, 2)
369+
// assert.GreaterOrEqual(t, "b", "a")
370+
// assert.GreaterOrEqual(t, "b", "b")
371371
func GreaterOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool {
372372
if h, ok := t.(tHelper); ok {
373373
h.Helper()
@@ -377,9 +377,9 @@ func GreaterOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...in
377377

378378
// Less asserts that the first element is less than the second
379379
//
380-
// assert.Less(t, 1, 2)
381-
// assert.Less(t, float64(1), float64(2))
382-
// assert.Less(t, "a", "b")
380+
// assert.Less(t, 1, 2)
381+
// assert.Less(t, float64(1), float64(2))
382+
// assert.Less(t, "a", "b")
383383
func Less(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool {
384384
if h, ok := t.(tHelper); ok {
385385
h.Helper()
@@ -389,10 +389,10 @@ func Less(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{})
389389

390390
// LessOrEqual asserts that the first element is less than or equal to the second
391391
//
392-
// assert.LessOrEqual(t, 1, 2)
393-
// assert.LessOrEqual(t, 2, 2)
394-
// assert.LessOrEqual(t, "a", "b")
395-
// assert.LessOrEqual(t, "b", "b")
392+
// assert.LessOrEqual(t, 1, 2)
393+
// assert.LessOrEqual(t, 2, 2)
394+
// assert.LessOrEqual(t, "a", "b")
395+
// assert.LessOrEqual(t, "b", "b")
396396
func LessOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool {
397397
if h, ok := t.(tHelper); ok {
398398
h.Helper()
@@ -402,8 +402,8 @@ func LessOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...inter
402402

403403
// Positive asserts that the specified element is positive
404404
//
405-
// assert.Positive(t, 1)
406-
// assert.Positive(t, 1.23)
405+
// assert.Positive(t, 1)
406+
// assert.Positive(t, 1.23)
407407
func Positive(t TestingT, e interface{}, msgAndArgs ...interface{}) bool {
408408
if h, ok := t.(tHelper); ok {
409409
h.Helper()
@@ -414,8 +414,8 @@ func Positive(t TestingT, e interface{}, msgAndArgs ...interface{}) bool {
414414

415415
// Negative asserts that the specified element is negative
416416
//
417-
// assert.Negative(t, -1)
418-
// assert.Negative(t, -1.23)
417+
// assert.Negative(t, -1)
418+
// assert.Negative(t, -1.23)
419419
func Negative(t TestingT, e interface{}, msgAndArgs ...interface{}) bool {
420420
if h, ok := t.(tHelper); ok {
421421
h.Helper()

assert/assertion_compare_can_convert.go

-16
This file was deleted.

0 commit comments

Comments
 (0)