mirror of
https://gitee.com/wanwujie/sub2api
synced 2026-04-23 08:04:45 +08:00
30 lines
640 B
Go
30 lines
640 B
Go
|
|
//go:build unit
|
||
|
|
|
||
|
|
package repository
|
||
|
|
|
||
|
|
import (
|
||
|
|
"testing"
|
||
|
|
|
||
|
|
"github.com/stretchr/testify/require"
|
||
|
|
)
|
||
|
|
|
||
|
|
func TestResolveEndpointColumn(t *testing.T) {
|
||
|
|
tests := []struct {
|
||
|
|
endpointType string
|
||
|
|
want string
|
||
|
|
}{
|
||
|
|
{"inbound", "ul.inbound_endpoint"},
|
||
|
|
{"upstream", "ul.upstream_endpoint"},
|
||
|
|
{"path", "ul.inbound_endpoint || ' -> ' || ul.upstream_endpoint"},
|
||
|
|
{"", "ul.inbound_endpoint"}, // default
|
||
|
|
{"unknown", "ul.inbound_endpoint"}, // fallback
|
||
|
|
}
|
||
|
|
|
||
|
|
for _, tc := range tests {
|
||
|
|
t.Run(tc.endpointType, func(t *testing.T) {
|
||
|
|
got := resolveEndpointColumn(tc.endpointType)
|
||
|
|
require.Equal(t, tc.want, got)
|
||
|
|
})
|
||
|
|
}
|
||
|
|
}
|