mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-09-20 15:04:17 +00:00
golangci-lint: enable and fix thelper linter
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
This commit is contained in:
@@ -39,6 +39,7 @@ import (
|
||||
// corresponding expected Action, and that each expected Action
|
||||
// has a corresponding actual Action.
|
||||
func CompareActions(t *testing.T, expected, actual []core.Action) {
|
||||
t.Helper()
|
||||
assert.Len(t, actual, len(expected))
|
||||
|
||||
for _, e := range expected {
|
||||
@@ -73,6 +74,7 @@ func CompareActions(t *testing.T, expected, actual []core.Action) {
|
||||
// with the provided decode func and has no extraneous fields, and that
|
||||
// the decoded patch matches the expected.
|
||||
func ValidatePatch(t *testing.T, action core.Action, expected interface{}, decodeFunc func(*json.Decoder) (interface{}, error)) {
|
||||
t.Helper()
|
||||
patchAction, ok := action.(core.PatchAction)
|
||||
require.True(t, ok, "action is not a PatchAction")
|
||||
|
||||
@@ -96,6 +98,7 @@ func TimesAreEqual(t1, t2 time.Time) bool {
|
||||
// This function exists in order to make sure time.Time and metav1.Time objects
|
||||
// can be compared correctly. See https://github.com/stretchr/testify/issues/502.
|
||||
func AssertDeepEqual(t *testing.T, expected, actual interface{}) bool {
|
||||
t.Helper()
|
||||
// By default, the equality.Semantic object doesn't have a function for comparing time.Times
|
||||
err := equality.Semantic.AddFunc(TimesAreEqual)
|
||||
if err != nil {
|
||||
@@ -114,6 +117,7 @@ func AssertDeepEqual(t *testing.T, expected, actual interface{}) bool {
|
||||
// AssertErrorMatches asserts that if expected is the empty string, actual
|
||||
// is nil, otherwise, that actual's error string matches expected.
|
||||
func AssertErrorMatches(t *testing.T, expected string, actual error) bool {
|
||||
t.Helper()
|
||||
if expected != "" {
|
||||
return assert.EqualError(t, actual, expected)
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ import (
|
||||
)
|
||||
|
||||
func NewFakeControllerRuntimeClientBuilder(t *testing.T) *k8sfake.ClientBuilder {
|
||||
t.Helper()
|
||||
scheme := runtime.NewScheme()
|
||||
|
||||
require.NoError(t, velerov1api.AddToScheme(scheme))
|
||||
@@ -46,6 +47,7 @@ func NewFakeControllerRuntimeClientBuilder(t *testing.T) *k8sfake.ClientBuilder
|
||||
}
|
||||
|
||||
func NewFakeControllerRuntimeClient(t *testing.T, initObjs ...runtime.Object) client.Client {
|
||||
t.Helper()
|
||||
scheme := runtime.NewScheme()
|
||||
|
||||
require.NoError(t, velerov1api.AddToScheme(scheme))
|
||||
@@ -62,5 +64,6 @@ func NewFakeControllerRuntimeWatchClient(
|
||||
t *testing.T,
|
||||
initObjs ...runtime.Object,
|
||||
) client.WithWatch {
|
||||
t.Helper()
|
||||
return NewFakeControllerRuntimeClientBuilder(t).WithRuntimeObjects(initObjs...).Build()
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ type TarWriter struct {
|
||||
}
|
||||
|
||||
func NewTarWriter(t *testing.T) *TarWriter {
|
||||
t.Helper()
|
||||
tw := new(TarWriter)
|
||||
tw.t = t
|
||||
tw.buf = new(bytes.Buffer)
|
||||
|
||||
Reference in New Issue
Block a user