Commit Graph

56 Commits

Author SHA1 Message Date
Flc゛
ac5e84d93c
feat(engine): Added OptionFunc and With (#3572)
* feat: Added `OptionFunc` and `With`

* fix: `With(opts...)` must be after `New`

* feat: improve New with

* fix: test

* optimize code

* optimize nolint

* optimize code

Signed-off-by: Flc゛ <four_leaf_clover@foxmail.com>

---------

Signed-off-by: Flc゛ <four_leaf_clover@foxmail.com>
2024-03-11 22:35:30 +08:00
Qt
6150c488e7
remove deprecated of package io/ioutil (#3395) 2022-11-17 22:35:55 +08:00
jessetang
aefae309a4
fix: test fmt.Println replace t.Error (#3328) 2022-11-06 17:12:11 +08:00
Amir Hossein
2c9e5fe47a
rename variable because collide with the imported package name (#3298)
* rename variable because collide with the imported package name

* handle unhandled error in context_1.17_test.go
2022-09-01 10:21:27 +08:00
thinkerou
4b68a5f12a
chore: update go.mod and remove space from copyright (#3158)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-28 10:42:28 +08:00
mstmdev
444e156fb1
Fix some tests (#3100)
* Sleep for one millisecond in the handler because the `Latency` will return `0s` sometimes and the test will fail

* The `TCPListener.File` is not supported by windows, it is unimplemented now

* Remove the `LF` in the `testdata/template/raw.tmpl`, because if set the git config `core.autocrlf=true`, will append `CR` to the raw.tmpl automatically, then test is failed on Windows
2022-04-21 18:21:46 +08:00
thinkerou
2bde107686
test support go1.18 (#2990) 2022-03-21 09:43:17 +08:00
thinkerou
87e40d6b15
feat: fix lint error (#3050) 2022-02-07 23:15:44 +08:00
涛叔
b40ded1837
Add h2c support (#1398) 2022-02-05 21:13:20 +08:00
Bo-Yi Wu
94153d1e19
test: expose performRequest func (#3012) 2022-01-02 19:07:44 +08:00
Notealot
39181329de
Tidy: Complete TrustedProxies feature (#2887) 2021-10-06 09:37:25 +08:00
Manu MA
bfc8ca285e
feat(engine): add trustedproxies and remoteIP (#2632)
Co-authored-by: Søren L. Hansen <soren@linux2go.dk>
Co-authored-by: Bo-Yi Wu <appleboy.tw@gmail.com>
Co-authored-by: thinkerou <thinkerou@gmail.com>
Co-authored-by: Javier Provecho Fernandez <javiertitan@gmail.com>
2021-04-06 11:37:25 +08:00
Dmitry Kutakov
31bbb10f34 Make silent debug info on tests (#1765)
* make silent log on tests

* fix coverage: check end-of-line at the end of debug msg
2019-02-18 10:10:45 +08:00
Dmitry Kutakov
a768f064d5 fix many redirects (#1760) (#1764)
* fix many redirects (#1760)

* fix @thinkerou review
2019-02-18 09:35:08 +08:00
Dmitry Kutakov
4867ff9634 fix Context.Next() - recheck len of handlers every iteration (#1745)
* fix Context.Next() - recheck len of handlers every iteration

* add tests when Context.reset() can be called inside of handler

TestEngineHandleContext
TestContextResetInHandler
TestRouterStaticFSFileNotFound

* Context.Next() - format to while style
2019-01-18 09:57:06 +08:00
Sergey Ponomarev
cfa092f4f0 Fix LoadHTML* tests (#1559)
Digging into the test code base I've found out that some of the tests for `LoadHTML*` methods are not reliable and efficient. They use timeouts to be sure that goroutine with the server has started. And even more, in old implementation, the server started only once – all the new instances silently failed due to the occupied network port.

Here is a short overview of the proposed changes: 
- it's not necessary to rely on timeouts, the server starts listening synchronously and returns control when it is ready
- once the server is run, it's stopped after a test passes
- dry out http server setup
- magic with empty closure return is eliminated 
- preserve router.RunTLS coverage with integration tests
2018-10-16 08:48:41 +08:00
Iskander (Alex) Sharipov
3f27866f80 simplify slice expressions: s[:] => s (#1541)
Found using https://go-critic.github.io/overview#unslice-ref
2018-09-12 21:21:26 +08:00
田欧
6159213462 unify test data (#1417)
mkdir a test data dir.
2018-08-12 23:38:31 +08:00
田欧
eeb57848ca update assert param(expect, actual) position (#1177) 2017-11-21 21:18:45 +08:00
田欧
1f377cb847 Add test cases for RunTLS and each mode (#1173)
* add RunTLS test cases and add debug/test mode cases

* add release mode cases
2017-11-21 09:27:57 +08:00
Bo-Yi Wu
6d071c1d36
Add load html file and func map.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2017-07-02 13:06:43 +08:00
Bo-Yi Wu
a40699e07f
add FuncMap testing
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2017-07-02 12:38:05 +08:00
sope
35f5df63e6 add custom Delims support (#860)
* Revert "Merge pull request #753 from gin-gonic/bug"

This reverts commit 556287ff08, reversing
changes made to 32cab500ec.

* Revert "Merge pull request #744 from aviddiviner/logger-fix"

This reverts commit c3bfd69303, reversing
changes made to 9177f01c28.

* add custom Delims support

* add some test for Delims

* remove the empty line for import native package

* remove unuseful comments
2017-05-29 03:03:49 -05:00
Javier Provecho Fernandez
3c3526f1f1 fix test and build 2016-04-15 01:35:22 +02:00
Javier Provecho Fernandez
9e930b9bdd lint code 2016-04-15 01:16:46 +02:00
Albin Gilles
1f2e53dfd1 Fix typo on gin_test.go
Fixes #550, change a duplicate assert on the Path of the route by an assert on Handler name associated with the route.
2016-03-09 08:29:01 +01:00
Philipp Meinen
9fd8aff56e tests: make path assertions aware of vendoring
The path of a package can change in a situation where
dependency vendoring is in use.
This change modifies gin's unit tests to allow such paths.
2015-08-23 00:13:41 +02:00
Manu Mtz-Almeida
a97c239b7a fixes unit tests 2015-08-16 16:36:47 +02:00
Manu Mtz-Almeida
fc5e355724 BasePath is not longer an exported field, but a method instead 2015-07-08 04:27:23 +02:00
Manu Mtz-Almeida
638377655d Add unit tests for LoadHTML in debug mode 2015-07-04 20:06:40 +02:00
Manu Mtz-Almeida
1a7ab6e4d5 Fixes gin.Routes() tests 2015-06-18 17:17:22 +02:00
Manu Mtz-Almeida
c7d2d82d01 gofmt 2015-06-07 04:26:30 +02:00
Manu Mtz-Almeida
45dd777693 List of routes 2015-06-07 04:20:39 +02:00
Manu Mtz-Almeida
ee021d06ea More unit tests 2015-06-04 04:32:18 +02:00
Manu Mtz-Almeida
766493c916 Fixes all unit tests 2015-05-31 22:35:49 +02:00
Manu Mtz-Almeida
835f66fdc9 404 not found performance improvements
benchmark            old ns/op     new ns/op     delta
Benchmark404         737           249           -66.21%
Benchmark404Many     2330          454           -80.52%

benchmark            old allocs     new allocs     delta
Benchmark404         3              0              -100.00%
Benchmark404Many     10             0              -100.00%

benchmark            old bytes     new bytes     delta
Benchmark404         115           68            -40.87%
Benchmark404Many     235           57            -75.74%
2015-05-30 14:45:13 +02:00
Manu Mtz-Almeida
022304e7d9 Better API for RouteGroup.Handle() 2015-05-19 23:22:35 +02:00
Manu Mtz-Almeida
0cb52ccef7 Improves unit test coverage 2015-05-19 02:29:32 +02:00
Manu Mtz-Almeida
3066c35754 Renames RouterGroup.absolutePath to .BasePath 2015-05-16 18:08:19 +02:00
Manu Mtz-Almeida
eb3e9293ed Renames []HandleFunc to HandlersChain 2015-05-07 11:30:01 +02:00
Manu Mtz-Almeida
f212ae7728 Updates tree.go + fixes + unit tests 2015-05-05 16:37:33 +02:00
Manu Mtz-Almeida
0a192fb0fa Tons of unit tests 2015-04-09 12:15:02 +02:00
Manu Mtz-Almeida
ac0ad2fed8 Improves unit tests 2015-04-08 02:58:35 +02:00
Manu Mtz-Almeida
615c62d736 Some cosmetic changes 2015-03-23 04:41:29 +01:00
Javier Provecho Fernandez
413d0f2296 Fix TestRouteNotOK2 with HTTP 405 2015-01-04 02:28:37 +01:00
Manu Mtz-Almeida
030706c39a Using absolutePath in static properly 2014-10-08 21:49:08 +02:00
Manu Mtz-Almeida
8e5397bfa0 Adds in-code license 2014-08-29 19:49:50 +02:00
Manu Mtz-Almeida
94f2f3f7eb Using test mode 2014-08-21 01:01:42 +02:00
Manu Mtz-Almeida
d85245b5aa Improves unit tests
- Reusing much more code
- More coverage
- Cleanup
- Fixes some cases
2014-08-18 19:48:48 +02:00
Sasha Myasoedov
6abe841c1f Splited tests into separate files 2014-08-08 14:48:15 +03:00