326 Commits

Author SHA1 Message Date
arseny
415d89281b Fix time.Time not equals bug
Adding test
2020-07-27 21:16:21 +10:00
arseny
1ebd9c5791 Fix PR comments 2020-07-27 21:16:21 +10:00
Pal Sivertsen
95a9d909e9 Add wrapper functions for errors Is and As funcs
This commit adds wrapper functions for Is and As functions from the
errors package.
2020-07-20 20:40:44 +10:00
Torkel Rogstad
51595dcf94 Allow comparing custom comparable types
Prior to this commit, this would not work:

```go
type myInt int
assert.Less(t, myInt(1), myInt(2)) // panic!
```

We add some type conversions, similarly to how `ObjectsAreEqualValues`
work. This allows us to compare `myInt` to `myInt`, as well as `myInt`
to `int`.
2020-06-22 19:40:53 +10:00
Ivo van der Wijk
b8f7d52a4a Rewrite test loops into individual test cases 2020-06-13 21:33:52 +10:00
Ivo van der Wijk
8a501b0fac make testcase definition local 2020-06-13 21:33:52 +10:00
Ivo van der Wijk
4bbffeac6c table-ify TestElementsMatch 2020-06-13 21:33:52 +10:00
Ivo van der Wijk
52b38ca424 table-ify, refactor (Not)Subset() 2020-06-13 21:33:52 +10:00
Ivo van der Wijk
0929293466 refactor, table-ify TestContains / TestNotContains 2020-06-13 21:33:52 +10:00
Ivo van der Wijk
67a4d91853 table-ify ObjectsAreEqual() 2020-06-13 21:33:52 +10:00
Ivo van der Wijk
5717c498e9 table-ify Equal() 2020-06-13 21:33:52 +10:00
Ivo van der Wijk
408bc6703a keep type definition local to function where used 2020-06-13 21:33:52 +10:00
Ivo van der Wijk
590942c47f table-ify Exactly 2020-06-13 21:33:52 +10:00
Ivo van der Wijk
9ffb85bbec clarify sets of tests 2020-06-13 21:33:52 +10:00
Ivo van der Wijk
51b7cfe385 rewrite NotEqual() tests to table tests 2020-06-13 21:33:52 +10:00
Ivo van der Wijk
07d1e00890 first attempt at table-ifying NotEqualValues tests 2020-06-13 21:33:52 +10:00
Ivo van der Wijk
f50e178a9f first attempt at table-ifying NotEqualValues tests 2020-06-13 21:33:52 +10:00
Boyan
3184a9e141 This reverts commit 0a813b5898c0ee8d00b4f13fae21ea5df8b35e74. 2020-06-05 20:47:15 +10:00
Boyan
6353e56395 This reverts commit 9d083cac4a26c76f8d92dff41d459f3f2fc0b911. 2020-06-05 20:47:15 +10:00
Boyan
656132404a This reverts commit 484fff1ace1f0acb84676a548b53477685c16414. 2020-06-05 20:47:15 +10:00
Boyan
46420cf544 This reverts commit 1a43b8334acb9df58064b765cd16675cc7c2c8b3. 2020-06-05 20:47:15 +10:00
Boyan
303198d014 Revert "allow body for HTTPBodyContains and HTTPBodyNotContains for
POST" PR #938

This reverts commit 136026fb259a9c69ea2655a0f83500d50713ccf8.
2020-06-05 20:47:15 +10:00
Ivo van der Wijk
004e3cb722 commit generated files 2020-05-27 08:39:56 +10:00
Ivo van der Wijk
ac1463f956 Implement NotEqualValues 2020-05-27 08:39:56 +10:00
Matt Gorzka
e72b029e2a new regex 2020-05-14 20:01:26 +10:00
zjx158094
d4e7ca1687 address comments 2020-05-14 19:53:33 +10:00
zjx158094
8329c5daa7 add test 2020-05-14 19:53:33 +10:00
zjx20
3ec00f620a assertion_compare: fix format string for numbers 2020-05-14 19:53:33 +10:00
Pedro de Brito
15aff29f35 docs: update Comparison function comment 2020-05-06 18:14:40 +10:00
Bryan Boreham
f7ef284eb4 Add a benchmark to time trivial call of NotNil 2020-05-04 21:01:24 +10:00
Bryan Boreham
e734bda58c Avoid calling Helper() on the happy path.
Helper() in the standard Go runtime fetches a stack trace from the
runtime, so is slow for calls that are made many times.

Helper() only makes a difference if the call throws an error, so move
it after the test in straightforward cases.
2020-05-04 21:01:24 +10:00
gohargasparyan
136026fb25 add test cases 2020-05-04 07:47:34 +10:00
gohargasparyan
1a43b8334a add test cases 2020-05-04 07:47:34 +10:00
gohargasparyan
484fff1ace didn't notice should run go generate 2020-05-04 07:47:34 +10:00
gohargasparyan
9d083cac4a go format 2020-05-04 07:47:34 +10:00
gohargasparyan
0a813b5898 allow body for HTTPBodyContains and HTTPBodyNotContains for POST 2020-05-04 07:47:34 +10:00
David Wragg
ca8e08c131 Support uint in InDelta and InEpsilon
InDelta and InEpsilon assertions on uint values would fail with
the error "Parameters must be numerical".
2020-04-29 21:29:26 +10:00
Dave Henderson
d3decad621 Update dependency to gopkg.in/yaml.v3
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
2020-04-28 07:45:39 +10:00
Martijn
bb468cc94d Remove unneeded return statements 2020-04-06 07:42:56 +10:00
Martijn
28b7455875 Ran go generate ./... 2020-04-06 07:42:56 +10:00
Martijn
e0afeb10e3 Fix whitespace issues 2020-04-06 07:42:56 +10:00
Martijn
1454493cee Add test for HTTPStatusCode
For purposes of the test, status code 101 is checked as this does not overlap with the other assertions. (HTTPSuccess, HTTPRedirect and HTTPError)
2020-04-06 07:42:56 +10:00
Martijn
f0828adbb3 Add HTTPStatusCode assertion
Allows for asserting a specific HTTP status code was returned instead of a general success, error or redirect assertion.
2020-04-06 07:42:56 +10:00
hectorj
012967472b Make InEpsilon fail when given a NaN
fixes #918
2020-04-02 22:34:25 +11:00
Martin Sucha
f6cbfc0d03 Print more details in ElementsMatch
It is not very helpful to print that the lengths differ when an
assertion fails, since that does not reveal what the cause of the issue
might be.

Let's print which elements are extra in each list, that should convey
the relevant information to the user. Also use spew to format the
objects, similar to what Equal does, to make the output more readable.
2020-03-14 21:17:20 +11:00
Henry Blyth
cb23521296 Test verbose Contains Fail message
If asserting an error contained in a string, includeElement will fail
but Contains will confusingly print both values as strings, which can
look like a testify problem instead of an assertion failure.
2020-03-10 08:59:40 +11:00
Jordan Christiansen
c12dcedf28 Include the type in assert.Contains error messages
Fixes #828
2020-03-10 08:59:40 +11:00
alexpantyukhin
6be346c1f1 rename order files to compare files 2020-03-09 08:00:09 +11:00
Alexander Pantyukhin
9388656beb fix language 2020-03-06 19:44:08 +11:00
Alexander Pantyukhin
2ca25e3fac fix for assertions 2020-03-06 19:44:08 +11:00