mirror of
https://github.com/fatedier/frp.git
synced 2025-07-27 07:35:07 +00:00
client, pkg, server, test: replaced 'interface{}' with 'any' (#4611)
This commit is contained in:
@@ -5,75 +5,75 @@ import (
|
||||
)
|
||||
|
||||
// ExpectEqual expects the specified two are the same, otherwise an exception raises
|
||||
func ExpectEqual(actual interface{}, extra interface{}, explain ...interface{}) {
|
||||
func ExpectEqual(actual any, extra any, explain ...any) {
|
||||
gomega.ExpectWithOffset(1, actual).To(gomega.Equal(extra), explain...)
|
||||
}
|
||||
|
||||
// ExpectEqualValues expects the specified two are the same, it not strict about type
|
||||
func ExpectEqualValues(actual interface{}, extra interface{}, explain ...interface{}) {
|
||||
func ExpectEqualValues(actual any, extra any, explain ...any) {
|
||||
gomega.ExpectWithOffset(1, actual).To(gomega.BeEquivalentTo(extra), explain...)
|
||||
}
|
||||
|
||||
func ExpectEqualValuesWithOffset(offset int, actual interface{}, extra interface{}, explain ...interface{}) {
|
||||
func ExpectEqualValuesWithOffset(offset int, actual any, extra any, explain ...any) {
|
||||
gomega.ExpectWithOffset(1+offset, actual).To(gomega.BeEquivalentTo(extra), explain...)
|
||||
}
|
||||
|
||||
// ExpectNotEqual expects the specified two are not the same, otherwise an exception raises
|
||||
func ExpectNotEqual(actual interface{}, extra interface{}, explain ...interface{}) {
|
||||
func ExpectNotEqual(actual any, extra any, explain ...any) {
|
||||
gomega.ExpectWithOffset(1, actual).NotTo(gomega.Equal(extra), explain...)
|
||||
}
|
||||
|
||||
// ExpectError expects an error happens, otherwise an exception raises
|
||||
func ExpectError(err error, explain ...interface{}) {
|
||||
func ExpectError(err error, explain ...any) {
|
||||
gomega.ExpectWithOffset(1, err).To(gomega.HaveOccurred(), explain...)
|
||||
}
|
||||
|
||||
func ExpectErrorWithOffset(offset int, err error, explain ...interface{}) {
|
||||
func ExpectErrorWithOffset(offset int, err error, explain ...any) {
|
||||
gomega.ExpectWithOffset(1+offset, err).To(gomega.HaveOccurred(), explain...)
|
||||
}
|
||||
|
||||
// ExpectNoError checks if "err" is set, and if so, fails assertion while logging the error.
|
||||
func ExpectNoError(err error, explain ...interface{}) {
|
||||
func ExpectNoError(err error, explain ...any) {
|
||||
ExpectNoErrorWithOffset(1, err, explain...)
|
||||
}
|
||||
|
||||
// ExpectNoErrorWithOffset checks if "err" is set, and if so, fails assertion while logging the error at "offset" levels above its caller
|
||||
// (for example, for call chain f -> g -> ExpectNoErrorWithOffset(1, ...) error would be logged for "f").
|
||||
func ExpectNoErrorWithOffset(offset int, err error, explain ...interface{}) {
|
||||
func ExpectNoErrorWithOffset(offset int, err error, explain ...any) {
|
||||
gomega.ExpectWithOffset(1+offset, err).NotTo(gomega.HaveOccurred(), explain...)
|
||||
}
|
||||
|
||||
func ExpectContainSubstring(actual, substr string, explain ...interface{}) {
|
||||
func ExpectContainSubstring(actual, substr string, explain ...any) {
|
||||
gomega.ExpectWithOffset(1, actual).To(gomega.ContainSubstring(substr), explain...)
|
||||
}
|
||||
|
||||
// ExpectConsistOf expects actual contains precisely the extra elements. The ordering of the elements does not matter.
|
||||
func ExpectConsistOf(actual interface{}, extra interface{}, explain ...interface{}) {
|
||||
func ExpectConsistOf(actual any, extra any, explain ...any) {
|
||||
gomega.ExpectWithOffset(1, actual).To(gomega.ConsistOf(extra), explain...)
|
||||
}
|
||||
|
||||
func ExpectContainElements(actual interface{}, extra interface{}, explain ...interface{}) {
|
||||
func ExpectContainElements(actual any, extra any, explain ...any) {
|
||||
gomega.ExpectWithOffset(1, actual).To(gomega.ContainElements(extra), explain...)
|
||||
}
|
||||
|
||||
func ExpectNotContainElements(actual interface{}, extra interface{}, explain ...interface{}) {
|
||||
func ExpectNotContainElements(actual any, extra any, explain ...any) {
|
||||
gomega.ExpectWithOffset(1, actual).NotTo(gomega.ContainElements(extra), explain...)
|
||||
}
|
||||
|
||||
// ExpectHaveKey expects the actual map has the key in the keyset
|
||||
func ExpectHaveKey(actual interface{}, key interface{}, explain ...interface{}) {
|
||||
func ExpectHaveKey(actual any, key any, explain ...any) {
|
||||
gomega.ExpectWithOffset(1, actual).To(gomega.HaveKey(key), explain...)
|
||||
}
|
||||
|
||||
// ExpectEmpty expects actual is empty
|
||||
func ExpectEmpty(actual interface{}, explain ...interface{}) {
|
||||
func ExpectEmpty(actual any, explain ...any) {
|
||||
gomega.ExpectWithOffset(1, actual).To(gomega.BeEmpty(), explain...)
|
||||
}
|
||||
|
||||
func ExpectTrue(actual interface{}, explain ...interface{}) {
|
||||
func ExpectTrue(actual any, explain ...any) {
|
||||
gomega.ExpectWithOffset(1, actual).Should(gomega.BeTrue(), explain...)
|
||||
}
|
||||
|
||||
func ExpectTrueWithOffset(offset int, actual interface{}, explain ...interface{}) {
|
||||
func ExpectTrueWithOffset(offset int, actual any, explain ...any) {
|
||||
gomega.ExpectWithOffset(1+offset, actual).Should(gomega.BeTrue(), explain...)
|
||||
}
|
||||
|
@@ -11,18 +11,18 @@ func nowStamp() string {
|
||||
return time.Now().Format(time.StampMilli)
|
||||
}
|
||||
|
||||
func log(level string, format string, args ...interface{}) {
|
||||
func log(level string, format string, args ...any) {
|
||||
fmt.Fprintf(ginkgo.GinkgoWriter, nowStamp()+": "+level+": "+format+"\n", args...)
|
||||
}
|
||||
|
||||
// Logf logs the info.
|
||||
func Logf(format string, args ...interface{}) {
|
||||
func Logf(format string, args ...any) {
|
||||
log("INFO", format, args...)
|
||||
}
|
||||
|
||||
// Failf logs the fail info, including a stack trace starts with its direct caller
|
||||
// (for example, for call chain f -> g -> Failf("foo", ...) error would be logged for "g").
|
||||
func Failf(format string, args ...interface{}) {
|
||||
func Failf(format string, args ...any) {
|
||||
msg := fmt.Sprintf(format, args...)
|
||||
skip := 1
|
||||
ginkgo.Fail(msg, skip)
|
||||
|
@@ -67,8 +67,8 @@ func (m *MockServers) Close() {
|
||||
os.Remove(m.udsEchoServer.BindAddr())
|
||||
}
|
||||
|
||||
func (m *MockServers) GetTemplateParams() map[string]interface{} {
|
||||
ret := make(map[string]interface{})
|
||||
func (m *MockServers) GetTemplateParams() map[string]any {
|
||||
ret := make(map[string]any)
|
||||
ret[TCPEchoServerPort] = m.tcpEchoServer.BindPort()
|
||||
ret[UDPEchoServerPort] = m.udpEchoServer.BindPort()
|
||||
ret[UDSEchoServerAddr] = m.udsEchoServer.BindAddr()
|
||||
@@ -76,7 +76,7 @@ func (m *MockServers) GetTemplateParams() map[string]interface{} {
|
||||
return ret
|
||||
}
|
||||
|
||||
func (m *MockServers) GetParam(key string) interface{} {
|
||||
func (m *MockServers) GetParam(key string) any {
|
||||
params := m.GetTemplateParams()
|
||||
if v, ok := params[key]; ok {
|
||||
return v
|
||||
|
@@ -42,7 +42,7 @@ type RequestExpect struct {
|
||||
f *Framework
|
||||
expectResp []byte
|
||||
expectError bool
|
||||
explain []interface{}
|
||||
explain []any
|
||||
}
|
||||
|
||||
func NewRequestExpect(f *Framework) *RequestExpect {
|
||||
@@ -51,7 +51,7 @@ func NewRequestExpect(f *Framework) *RequestExpect {
|
||||
f: f,
|
||||
expectResp: []byte(consts.TestString),
|
||||
expectError: false,
|
||||
explain: make([]interface{}, 0),
|
||||
explain: make([]any, 0),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ func (e *RequestExpect) ExpectError(expectErr bool) *RequestExpect {
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *RequestExpect) Explain(explain ...interface{}) *RequestExpect {
|
||||
func (e *RequestExpect) Explain(explain ...any) *RequestExpect {
|
||||
e.explain = explain
|
||||
return e
|
||||
}
|
||||
|
Reference in New Issue
Block a user