mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-19 18:02:01 +00:00
Merge pull request #115961 from pohly/e2e-framework-deprecate-gomega-wrappers
e2e framework: deprecate gomega wrappers
This commit is contained in:
commit
6f68a13696
@ -41,33 +41,6 @@ do
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
errors_expect_error=()
|
|
||||||
for file in "${all_e2e_files[@]}"
|
|
||||||
do
|
|
||||||
if grep "Expect(.*)\.To(.*HaveOccurred()" "${file}" > /dev/null
|
|
||||||
then
|
|
||||||
errors_expect_error+=( "${file}" )
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
errors_expect_no_equal=()
|
|
||||||
for file in "${all_e2e_files[@]}"
|
|
||||||
do
|
|
||||||
if grep -E "Expect\(.*\)\.(NotTo|ToNot)\((gomega\.Equal|Equal)" "${file}" > /dev/null
|
|
||||||
then
|
|
||||||
errors_expect_no_equal+=( "${file}" )
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
errors_expect_equal=()
|
|
||||||
for file in "${all_e2e_files[@]}"
|
|
||||||
do
|
|
||||||
if grep -E "Expect\(.*\)\.To\((gomega\.Equal|Equal)" "${file}" > /dev/null
|
|
||||||
then
|
|
||||||
errors_expect_equal+=( "${file}" )
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
all_e2e_framework_files=()
|
all_e2e_framework_files=()
|
||||||
kube::util::read-array all_e2e_framework_files < <(find test/e2e/framework/ -name '*.go' | grep -v "_test.go")
|
kube::util::read-array all_e2e_framework_files < <(find test/e2e/framework/ -name '*.go' | grep -v "_test.go")
|
||||||
errors_framework_contains_tests=()
|
errors_framework_contains_tests=()
|
||||||
@ -93,48 +66,6 @@ if [ ${#errors_expect_no_error[@]} -ne 0 ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ${#errors_expect_error[@]} -ne 0 ]; then
|
|
||||||
{
|
|
||||||
echo "Errors:"
|
|
||||||
for err in "${errors_expect_error[@]}"; do
|
|
||||||
echo "$err"
|
|
||||||
done
|
|
||||||
echo
|
|
||||||
echo 'The above files need to use framework.ExpectError(err) instead of '
|
|
||||||
echo 'Expect(err).To(HaveOccurred()) or gomega.Expect(err).To(gomega.HaveOccurred())'
|
|
||||||
echo
|
|
||||||
} >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ${#errors_expect_no_equal[@]} -ne 0 ]; then
|
|
||||||
{
|
|
||||||
echo "Errors:"
|
|
||||||
for err in "${errors_expect_no_equal[@]}"; do
|
|
||||||
echo "$err"
|
|
||||||
done
|
|
||||||
echo
|
|
||||||
echo 'The above files need to use framework.ExpectNotEqual(foo, bar) instead of '
|
|
||||||
echo 'Expect(foo).NotTo(Equal(bar)) or gomega.Expect(foo).NotTo(gomega.Equal(bar))'
|
|
||||||
echo
|
|
||||||
} >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ${#errors_expect_equal[@]} -ne 0 ]; then
|
|
||||||
{
|
|
||||||
echo "Errors:"
|
|
||||||
for err in "${errors_expect_equal[@]}"; do
|
|
||||||
echo "$err"
|
|
||||||
done
|
|
||||||
echo
|
|
||||||
echo 'The above files need to use framework.ExpectEqual(foo, bar) instead of '
|
|
||||||
echo 'Expect(foo).To(Equal(bar)) or gomega.Expect(foo).To(gomega.Equal(bar))'
|
|
||||||
echo
|
|
||||||
} >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ${#errors_framework_contains_tests[@]} -ne 0 ]; then
|
if [ ${#errors_framework_contains_tests[@]} -ne 0 ]; then
|
||||||
{
|
{
|
||||||
echo "Errors:"
|
echo "Errors:"
|
||||||
|
@ -293,16 +293,24 @@ func (f *FailureError) backtrace() {
|
|||||||
var ErrFailure error = FailureError{}
|
var ErrFailure error = FailureError{}
|
||||||
|
|
||||||
// ExpectEqual expects the specified two are the same, otherwise an exception raises
|
// ExpectEqual expects the specified two are the same, otherwise an exception raises
|
||||||
|
//
|
||||||
|
// Deprecated: use gomega.Expect().To(gomega.BeEqual())
|
||||||
func ExpectEqual(actual interface{}, extra interface{}, explain ...interface{}) {
|
func ExpectEqual(actual interface{}, extra interface{}, explain ...interface{}) {
|
||||||
gomega.ExpectWithOffset(1, actual).To(gomega.Equal(extra), explain...)
|
gomega.ExpectWithOffset(1, actual).To(gomega.Equal(extra), explain...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ExpectNotEqual expects the specified two are not the same, otherwise an exception raises
|
// ExpectNotEqual expects the specified two are not the same, otherwise an exception raises
|
||||||
|
//
|
||||||
|
// Deprecated: use gomega.Expect().ToNot(gomega.BeEqual())
|
||||||
func ExpectNotEqual(actual interface{}, extra interface{}, explain ...interface{}) {
|
func ExpectNotEqual(actual interface{}, extra interface{}, explain ...interface{}) {
|
||||||
gomega.ExpectWithOffset(1, actual).NotTo(gomega.Equal(extra), explain...)
|
gomega.ExpectWithOffset(1, actual).NotTo(gomega.Equal(extra), explain...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ExpectError expects an error happens, otherwise an exception raises
|
// ExpectError expects an error happens, otherwise an exception raises
|
||||||
|
//
|
||||||
|
// Deprecated: use gomega.Expect().To(gomega.HaveOccurred()) or (better!) check
|
||||||
|
// specifically for the error that is expected with
|
||||||
|
// gomega.Expect().To(gomega.MatchError(gomega.ContainSubstring()))
|
||||||
func ExpectError(err error, explain ...interface{}) {
|
func ExpectError(err error, explain ...interface{}) {
|
||||||
gomega.ExpectWithOffset(1, err).To(gomega.HaveOccurred(), explain...)
|
gomega.ExpectWithOffset(1, err).To(gomega.HaveOccurred(), explain...)
|
||||||
}
|
}
|
||||||
@ -356,16 +364,22 @@ func ExpectNoErrorWithOffset(offset int, err error, explain ...interface{}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ExpectConsistOf expects actual contains precisely the extra elements. The ordering of the elements does not matter.
|
// ExpectConsistOf expects actual contains precisely the extra elements. The ordering of the elements does not matter.
|
||||||
|
//
|
||||||
|
// Deprecated: use gomega.Expect().To(gomega.ConsistOf()) instead
|
||||||
func ExpectConsistOf(actual interface{}, extra interface{}, explain ...interface{}) {
|
func ExpectConsistOf(actual interface{}, extra interface{}, explain ...interface{}) {
|
||||||
gomega.ExpectWithOffset(1, actual).To(gomega.ConsistOf(extra), explain...)
|
gomega.ExpectWithOffset(1, actual).To(gomega.ConsistOf(extra), explain...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ExpectHaveKey expects the actual map has the key in the keyset
|
// ExpectHaveKey expects the actual map has the key in the keyset
|
||||||
|
//
|
||||||
|
// Deprecated: use gomega.Expect().To(gomega.HaveKey()) instead
|
||||||
func ExpectHaveKey(actual interface{}, key interface{}, explain ...interface{}) {
|
func ExpectHaveKey(actual interface{}, key interface{}, explain ...interface{}) {
|
||||||
gomega.ExpectWithOffset(1, actual).To(gomega.HaveKey(key), explain...)
|
gomega.ExpectWithOffset(1, actual).To(gomega.HaveKey(key), explain...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ExpectEmpty expects actual is empty
|
// ExpectEmpty expects actual is empty
|
||||||
|
//
|
||||||
|
// Deprecated: use gomega.Expect().To(gomega.BeEmpty()) instead
|
||||||
func ExpectEmpty(actual interface{}, explain ...interface{}) {
|
func ExpectEmpty(actual interface{}, explain ...interface{}) {
|
||||||
gomega.ExpectWithOffset(1, actual).To(gomega.BeEmpty(), explain...)
|
gomega.ExpectWithOffset(1, actual).To(gomega.BeEmpty(), explain...)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user