v2ray-core/app/router/rules/router_test.go

28 lines
693 B
Go
Raw Normal View History

2015-12-07 21:47:47 +00:00
package rules_test
import (
"testing"
2015-12-07 21:47:47 +00:00
. "github.com/v2ray/v2ray-core/app/router/rules"
testinconfig "github.com/v2ray/v2ray-core/app/router/rules/testing"
v2net "github.com/v2ray/v2ray-core/common/net"
v2testing "github.com/v2ray/v2ray-core/testing"
"github.com/v2ray/v2ray-core/testing/assert"
)
func TestSimpleRouter(t *testing.T) {
v2testing.Current(t)
2015-12-07 21:47:47 +00:00
router := NewRouter().AddRule(
&testinconfig.TestRule{
TagValue: "test",
Function: func(dest v2net.Destination) bool {
return dest.IsTCP()
},
2015-12-07 21:47:47 +00:00
})
2015-12-16 22:53:38 +00:00
tag, err := router.TakeDetour(v2net.TCPDestination(v2net.DomainAddress("v2ray.com"), 80))
assert.Error(err).IsNil()
2015-12-02 15:41:19 +00:00
assert.StringLiteral(tag).Equals("test")
}