mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-17 22:32:26 +08:00
add unit test
This commit is contained in:
parent
56fbadcde6
commit
feaee20a81
@ -55,6 +55,13 @@ func TestRunEmpty(t *testing.T) {
|
|||||||
testRequest(t, "http://localhost:8080/example")
|
testRequest(t, "http://localhost:8080/example")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestTrustedCIDRsForRun(t *testing.T) {
|
||||||
|
os.Setenv("PORT", "")
|
||||||
|
router := New()
|
||||||
|
router.TrustedProxies = []string{"hello/world"}
|
||||||
|
assert.Error(t, router.Run(":8080"))
|
||||||
|
}
|
||||||
|
|
||||||
func TestRunTLS(t *testing.T) {
|
func TestRunTLS(t *testing.T) {
|
||||||
router := New()
|
router := New()
|
||||||
go func() {
|
go func() {
|
||||||
|
@ -647,6 +647,15 @@ func TestPrepareTrustedCIRDsWith(t *testing.T) {
|
|||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// nil value
|
||||||
|
{
|
||||||
|
r.TrustedProxies = nil
|
||||||
|
trustedCIDRs, err := r.prepareTrustedCIDRs()
|
||||||
|
|
||||||
|
assert.Nil(t, trustedCIDRs)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseCIDR(cidr string) *net.IPNet {
|
func parseCIDR(cidr string) *net.IPNet {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user