mirror of
https://github.com/yusing/godoxy.git
synced 2026-02-19 17:07:42 +01:00
- Introduced `NewTestRoute` function to simplify route creation in benchmark tests. - Replaced direct route validation and starting with error handling using `require.NoError`. - Updated server retrieval to use `common.ProxyHTTPAddr` for consistency. - Improved logging for HTTP route addition errors in `AddRoute` method. * fix(tcp): wrap proxy proto listener before acl * refactor(entrypoint): propagate errors from route registration and stream serving * fix(docs): correct swagger and package README
40 lines
874 B
Go
40 lines
874 B
Go
package route
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
route "github.com/yusing/godoxy/internal/route/types"
|
|
"github.com/yusing/godoxy/internal/types"
|
|
)
|
|
|
|
func TestReverseProxyRoute(t *testing.T) {
|
|
t.Run("LinkToLoadBalancer", func(t *testing.T) {
|
|
cfg := Route{
|
|
Alias: "test",
|
|
Scheme: route.SchemeHTTP,
|
|
Host: "example.com",
|
|
Port: Port{Proxy: 80},
|
|
LoadBalance: &types.LoadBalancerConfig{
|
|
Link: "test",
|
|
},
|
|
}
|
|
cfg1 := Route{
|
|
Alias: "test1",
|
|
Scheme: route.SchemeHTTP,
|
|
Host: "example.com",
|
|
Port: Port{Proxy: 80},
|
|
LoadBalance: &types.LoadBalancerConfig{
|
|
Link: "test",
|
|
},
|
|
}
|
|
r, err := NewStartedTestRoute(t, &cfg)
|
|
require.NoError(t, err)
|
|
assert.NotNil(t, r)
|
|
r2, err := NewStartedTestRoute(t, &cfg1)
|
|
require.NoError(t, err)
|
|
assert.NotNil(t, r2)
|
|
})
|
|
}
|