mirror of
https://github.com/fatedier/frp.git
synced 2025-07-14 18:01:06 +07:00
more e2e tests (#1845)
This commit is contained in:
@ -6,8 +6,46 @@ import (
|
||||
"github.com/fatedier/frp/test/e2e/pkg/request"
|
||||
)
|
||||
|
||||
func ExpectTCPReuqest(port int, in, out []byte, timeout time.Duration) {
|
||||
res, err := request.SendTCPRequest(port, in, timeout)
|
||||
ExpectNoError(err)
|
||||
ExpectEqual(string(out), res)
|
||||
func ExpectRequest(protocol string, port int, in, out []byte, timeout time.Duration, explain ...interface{}) {
|
||||
switch protocol {
|
||||
case "tcp":
|
||||
ExpectTCPRequest(port, in, out, timeout, explain...)
|
||||
case "udp":
|
||||
ExpectUDPRequest(port, in, out, timeout, explain...)
|
||||
default:
|
||||
Failf("ExpectRequest not support protocol: %s", protocol)
|
||||
}
|
||||
}
|
||||
|
||||
func ExpectRequestError(protocol string, port int, in []byte, timeout time.Duration, explain ...interface{}) {
|
||||
switch protocol {
|
||||
case "tcp":
|
||||
ExpectTCPRequestError(port, in, timeout, explain...)
|
||||
case "udp":
|
||||
ExpectUDPRequestError(port, in, timeout, explain...)
|
||||
default:
|
||||
Failf("ExpectRequestError not support protocol: %s", protocol)
|
||||
}
|
||||
}
|
||||
|
||||
func ExpectTCPRequest(port int, in, out []byte, timeout time.Duration, explain ...interface{}) {
|
||||
res, err := request.SendTCPRequest(port, in, timeout)
|
||||
ExpectNoError(err, explain...)
|
||||
ExpectEqual(string(out), res, explain...)
|
||||
}
|
||||
|
||||
func ExpectTCPRequestError(port int, in []byte, timeout time.Duration, explain ...interface{}) {
|
||||
_, err := request.SendTCPRequest(port, in, timeout)
|
||||
ExpectError(err, explain...)
|
||||
}
|
||||
|
||||
func ExpectUDPRequest(port int, in, out []byte, timeout time.Duration, explain ...interface{}) {
|
||||
res, err := request.SendUDPRequest(port, in, timeout)
|
||||
ExpectNoError(err, explain...)
|
||||
ExpectEqual(string(out), res, explain...)
|
||||
}
|
||||
|
||||
func ExpectUDPRequestError(port int, in []byte, timeout time.Duration, explain ...interface{}) {
|
||||
_, err := request.SendUDPRequest(port, in, timeout)
|
||||
ExpectError(err, explain...)
|
||||
}
|
||||
|
Reference in New Issue
Block a user