Commit bbf5da3
committed
remove use of deprecated github.com/bmizerany/assert package
The github.com/bmizerany/assert module has been deprecated and is no
longer maintained. In addition, the dependency brings various indirect
dependencies with it;
module github.com/fluent/fluent-logger-golang
go 1.19
require (
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869
github.com/tinylib/msgp v1.1.6
)
require (
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/philhofer/fwd v1.1.1 // indirect
github.com/rogpeppe/go-internal v1.9.0 // indirect
)
The assertion package itself also looks to have some issues. For example,
it's not marked as a `t.Helper()`, and while it includes the location of
the error in the output, the failures are prefixed with the location of
the assertion itself, which is somewhat confusing:
=== RUN Test_New_itShouldUseDefaultConfigValuesIfNoOtherProvided
assert.go:15: /Users/thajeztah/go/src/github.com/fluent/fluent-logger-golang/fluent/fluent_test.go:275
assert.go:62: ! Unexpected: <24224>
--- FAIL: Test_New_itShouldUseDefaultConfigValuesIfNoOtherProvided (0.00s)
=== RUN Test_New_itShouldUseUnixDomainSocketIfUnixSocketSpecified
assert.go:15: /Users/thajeztah/go/src/github.com/fluent/fluent-logger-golang/fluent/fluent_test.go:306
assert.go:62: ! Unexpected: <"unix">
--- FAIL: Test_New_itShouldUseUnixDomainSocketIfUnixSocketSpecified (0.00s)
=== RUN Test_New_itShouldUseConfigValuesFromArguments
assert.go:15: /Users/thajeztah/go/src/github.com/fluent/fluent-logger-golang/fluent/fluent_test.go:327
assert.go:62: ! Unexpected: <6666>
--- FAIL: Test_New_itShouldUseConfigValuesFromArguments (0.00s)
=== RUN Test_New_itShouldUseConfigValuesFromMashalAsJSONArgument
assert.go:15: /Users/thajeztah/go/src/github.com/fluent/fluent-logger-golang/fluent/fluent_test.go:333
assert.go:62: ! Unexpected: <true>
--- FAIL: Test_New_itShouldUseConfigValuesFromMashalAsJSONArgument (0.00s)
=== CONT TestNoPanicOnAsyncClose/Channel_closed_before_write
assert.go:15: /Users/thajeztah/go/src/github.com/fluent/fluent-logger-golang/fluent/fluent_test.go:653
=== CONT TestNoPanicOnAsyncClose/Channel_not_closed_at_all
assert.go:15: /Users/thajeztah/go/src/github.com/fluent/fluent-logger-golang/fluent/fluent_test.go:655
=== CONT TestNoPanicOnAsyncClose/Channel_closed_before_write
assert.go:62: ! Unexpected: <&errors.errorString{s:"fluent#appendBuffer: Logger already closed"}>
=== CONT TestNoPanicOnAsyncClose/Channel_not_closed_at_all
assert.go:62: ! Unexpected: <<nil>>
While a good assertion library can help (for example by printing a rich
diff output if a struct does not match), a look at how it's used shows
that most cases are comparing primitive types (int, string, bool). This
patch swaps the library for a local `assertEqual()` utility. With this
patch, test-failures look like the example below:
=== RUN Test_New_itShouldUseDefaultConfigValuesIfNoOtherProvided
fluent_test.go:281: got: '24224', expected: '24224'
fluent_test.go:282: got: '127.0.0.1', expected: '127.0.0.1'
fluent_test.go:283: got: '3s', expected: '3s'
fluent_test.go:284: got: '0s', expected: '0s'
fluent_test.go:285: got: '8192', expected: '8192'
fluent_test.go:286: got: 'tcp', expected: 'tcp'
fluent_test.go:287: got: '', expected: ''
--- FAIL: Test_New_itShouldUseDefaultConfigValuesIfNoOtherProvided (0.00s)
=== RUN Test_New_itShouldUseUnixDomainSocketIfUnixSocketSpecified
fluent_test.go:312: got: 'unix', expected: 'unix'
fluent_test.go:313: got: '/tmp/fluent-logger-golang.sock', expected: '/tmp/fluent-logger-golang.sock'
--- FAIL: Test_New_itShouldUseUnixDomainSocketIfUnixSocketSpecified (0.00s)
=== RUN Test_New_itShouldUseConfigValuesFromArguments
fluent_test.go:333: got: '6666', expected: '6666'
fluent_test.go:334: got: 'foobarhost', expected: 'foobarhost'
--- FAIL: Test_New_itShouldUseConfigValuesFromArguments (0.00s)
=== RUN Test_New_itShouldUseConfigValuesFromMashalAsJSONArgument
fluent_test.go:339: got: 'true', expected: 'true'
--- FAIL: Test_New_itShouldUseConfigValuesFromMashalAsJSONArgument (0.00s)
=== RUN TestJsonConfig
fluent_test.go:441: got: '{FluentPort:8888 FluentHost:localhost FluentNetwork:tcp FluentSocketPath:/var/tmp/fluent.sock Timeout:3µs WriteTimeout:6µs BufferLimit:10 RetryWait:5 MaxRetry:3 MaxRetryWait:0 TagPrefix:fluent Async:false ForceStopAsyncSend:false AsyncResultCallback:<nil> AsyncConnect:false MarshalAsJSON:true AsyncReconnectInterval:0 SubSecondPrecision:false RequestAck:false TlsInsecureSkipVerify:false}', expected: '{FluentPort:8888 FluentHost:localhost FluentNetwork:tcp FluentSocketPath:/var/tmp/fluent.sock Timeout:3µs WriteTimeout:6µs BufferLimit:10 RetryWait:5 MaxRetry:3 MaxRetryWait:0 TagPrefix:fluent Async:false ForceStopAsyncSend:false AsyncResultCallback:<nil> AsyncConnect:false MarshalAsJSON:true AsyncReconnectInterval:0 SubSecondPrecision:false RequestAck:false TlsInsecureSkipVerify:false}'
--- FAIL: TestJsonConfig (0.00s)
=== CONT TestPostWithTime/without_Async
fluent_test.go:177: got: '["acme.tag_name",1482493046,{"foo":"bar"},{}]', expected: '["acme.tag_name",1482493046,{"foo":"bar"},{}]'
fluent_test.go:177: got: '["acme.tag_name",1482493050,{"fluentd":"is awesome"},{}]', expected: '["acme.tag_name",1482493050,{"fluentd":"is awesome"},{}]'
fluent_test.go:177: got: '["acme.tag_name",1634263200,{"welcome":"to use"},{}]', expected: '["acme.tag_name",1634263200,{"welcome":"to use"},{}]'
=== CONT TestPostWithTime/with_Async
fluent_test.go:177: got: '["acme.tag_name",1482493046,{"foo":"bar"},{}]', expected: '["acme.tag_name",1482493046,{"foo":"bar"},{}]'
fluent_test.go:177: got: '["acme.tag_name",1482493050,{"fluentd":"is awesome"},{}]', expected: '["acme.tag_name",1482493050,{"fluentd":"is awesome"},{}]'
fluent_test.go:177: got: '["acme.tag_name",1634263200,{"welcome":"to use"},{}]', expected: '["acme.tag_name",1634263200,{"welcome":"to use"},{}]'
=== CONT TestReconnectAndResendAfterTransientFailure/with_Async
fluent_test.go:177: got: '["tag_name",1482493046,{"foo":"bar"},{}]', expected: '["tag_name",1482493046,{"foo":"bar"},{}]'
=== CONT TestReconnectAndResendAfterTransientFailure/without_Async
fluent_test.go:177: got: '["tag_name",1482493046,{"foo":"bar"},{}]', expected: '["tag_name",1482493046,{"foo":"bar"},{}]'
fluent_test.go:177: got: '["tag_name",1482493050,{"fluentd":"is awesome"},{}]', expected: '["tag_name",1482493050,{"fluentd":"is awesome"},{}]'
=== CONT TestReconnectAndResendAfterTransientFailure/with_Async
fluent_test.go:177: got: '["tag_name",1482493050,{"fluentd":"is awesome"},{}]', expected: '["tag_name",1482493050,{"fluentd":"is awesome"},{}]'
=== CONT TestNoPanicOnAsyncClose/Channel_closed_before_write
fluent_test.go:657: got: 'fluent#appendBuffer: Logger already closed', expected: 'fluent#appendBuffer: Logger already closed'
=== CONT TestNoPanicOnAsyncClose/Channel_not_closed_at_all
fluent_test.go:659: got: '<nil>', expected: '<nil>'
The list of dependencies have also been reduced with this patch:
module github.com/fluent/fluent-logger-golang
go 1.19
require github.com/tinylib/msgp v1.1.6
require github.com/philhofer/fwd v1.1.1 // indirect
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>1 parent 30d6825 commit bbf5da3
3 files changed
+35
-57
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | 16 | | |
18 | 17 | | |
19 | 18 | | |
| |||
162 | 161 | | |
163 | 162 | | |
164 | 163 | | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
165 | 173 | | |
166 | 174 | | |
167 | 175 | | |
168 | 176 | | |
169 | | - | |
170 | | - | |
171 | | - | |
| 177 | + | |
| 178 | + | |
172 | 179 | | |
173 | 180 | | |
174 | 181 | | |
| |||
272 | 279 | | |
273 | 280 | | |
274 | 281 | | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
282 | 289 | | |
283 | 290 | | |
284 | 291 | | |
| |||
302 | 309 | | |
303 | 310 | | |
304 | 311 | | |
305 | | - | |
306 | | - | |
| 312 | + | |
| 313 | + | |
307 | 314 | | |
308 | 315 | | |
309 | 316 | | |
| |||
322 | 329 | | |
323 | 330 | | |
324 | 331 | | |
325 | | - | |
326 | | - | |
| 332 | + | |
| 333 | + | |
327 | 334 | | |
328 | 335 | | |
329 | 336 | | |
330 | 337 | | |
331 | | - | |
| 338 | + | |
332 | 339 | | |
333 | 340 | | |
334 | 341 | | |
| |||
431 | 438 | | |
432 | 439 | | |
433 | 440 | | |
434 | | - | |
435 | | - | |
436 | | - | |
| 441 | + | |
437 | 442 | | |
438 | 443 | | |
439 | 444 | | |
| |||
643 | 648 | | |
644 | 649 | | |
645 | 650 | | |
646 | | - | |
| 651 | + | |
647 | 652 | | |
648 | | - | |
| 653 | + | |
649 | 654 | | |
650 | | - | |
| 655 | + | |
651 | 656 | | |
652 | 657 | | |
653 | 658 | | |
| |||
755 | 760 | | |
756 | 761 | | |
757 | 762 | | |
758 | | - | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
759 | 766 | | |
760 | 767 | | |
761 | | - | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
762 | 771 | | |
763 | 772 | | |
764 | 773 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
| 5 | + | |
9 | 6 | | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
| 7 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | 1 | | |
11 | 2 | | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | 3 | | |
20 | 4 | | |
21 | | - | |
22 | | - | |
23 | | - | |
0 commit comments