diff options
author | David Anderson <[email protected]> | 2017-07-06 00:29:51 -0700 |
---|---|---|
committer | Dave Anderson <[email protected]> | 2017-07-06 21:36:14 -0700 |
commit | 815c9425f1ad46ffd3a3fb1bbefc05440072e4a4 (patch) | |
tree | 199b42d5595dad7c0e2aef8ea7500abe3fa4d55b /tcpproxy_test.go | |
parent | 2065af4b1e2d181a987a23f64c66f43e474469ff (diff) |
Merge matcher and route into an interface that yields a Target.
This allows routes to compute a target at match time, instead of being
statically mapped to a Target at register time.
Diffstat (limited to 'tcpproxy_test.go')
-rw-r--r-- | tcpproxy_test.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/tcpproxy_test.go b/tcpproxy_test.go index 45d8b0e..7150372 100644 --- a/tcpproxy_test.go +++ b/tcpproxy_test.go @@ -27,6 +27,10 @@ import ( "testing" ) +type noopTarget struct{} + +func (t *noopTarget) HandleConn(net.Conn) {} + func TestMatchHTTPHost(t *testing.T) { tests := []struct { name string @@ -53,6 +57,7 @@ func TestMatchHTTPHost(t *testing.T) { want: true, }, } + target := &noopTarget{} for i, tt := range tests { name := tt.name if name == "" { @@ -60,8 +65,8 @@ func TestMatchHTTPHost(t *testing.T) { } t.Run(name, func(t *testing.T) { br := bufio.NewReader(tt.r) - var matcher matcher = httpHostMatch(tt.host) - got := matcher.match(br) + r := httpHostMatch{tt.host, target} + got := r.match(br) != nil if got != tt.want { t.Fatalf("match = %v; want %v", got, tt.want) } |