mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-01-03 11:45:20 +00:00
fix empty rule from testifylint
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
This commit is contained in:
@@ -260,7 +260,6 @@ linters:
|
||||
testifylint:
|
||||
# TODO: enable them all
|
||||
disable:
|
||||
- empty # FIXME
|
||||
- equal-values # FIXME
|
||||
- float-compare
|
||||
- go-require
|
||||
|
||||
@@ -190,7 +190,7 @@ func Test_getDataPathConfigs(t *testing.T) {
|
||||
s.getDataPathConfigs()
|
||||
assert.Equal(t, test.expectConfigs, s.dataPathConfigs)
|
||||
if test.expectLog == "" {
|
||||
assert.Equal(t, "", logBuffer)
|
||||
assert.Empty(t, logBuffer)
|
||||
} else {
|
||||
assert.Contains(t, logBuffer, test.expectLog)
|
||||
}
|
||||
@@ -408,7 +408,7 @@ func Test_getDataPathConcurrentNum(t *testing.T) {
|
||||
num := s.getDataPathConcurrentNum(defaultNum)
|
||||
assert.Equal(t, test.expectNum, num)
|
||||
if test.expectLog == "" {
|
||||
assert.Equal(t, "", logBuffer)
|
||||
assert.Empty(t, logBuffer)
|
||||
} else {
|
||||
assert.Contains(t, logBuffer, test.expectLog)
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ func TestGetOptionalStringFlag(t *testing.T) {
|
||||
|
||||
// not specified
|
||||
cmd := &cobra.Command{}
|
||||
assert.Equal(t, "", GetOptionalStringFlag(cmd, flagName))
|
||||
assert.Empty(t, GetOptionalStringFlag(cmd, flagName))
|
||||
|
||||
// specified
|
||||
cmd.Flags().String(flagName, "value", "")
|
||||
|
||||
@@ -22,7 +22,7 @@ func TestSetOfEnum(t *testing.T) {
|
||||
|
||||
func TestTypeOfEnum(t *testing.T) {
|
||||
enum := NewEnum("a", "a", "b", "c")
|
||||
assert.Equal(t, "", enum.Type())
|
||||
assert.Empty(t, enum.Type())
|
||||
}
|
||||
|
||||
func TestAllowedValuesOfEnum(t *testing.T) {
|
||||
|
||||
@@ -34,7 +34,7 @@ func TestClearOutputFlagDefault(t *testing.T) {
|
||||
BindFlags(cmd.Flags())
|
||||
cmd.Flags().Set("output", "json")
|
||||
ClearOutputFlagDefault(cmd)
|
||||
assert.Equal(t, "", cmd.Flags().Lookup("output").Value.String())
|
||||
assert.Empty(t, cmd.Flags().Lookup("output").Value.String())
|
||||
}
|
||||
|
||||
func cmdWithFormat(use string, format string) *cobra.Command {
|
||||
|
||||
@@ -54,13 +54,13 @@ func TestResources(t *testing.T) {
|
||||
|
||||
crb := ClusterRoleBinding(DefaultVeleroNamespace)
|
||||
// The CRB is a cluster-scoped resource
|
||||
assert.Equal(t, "", crb.ObjectMeta.Namespace)
|
||||
assert.Empty(t, crb.ObjectMeta.Namespace)
|
||||
assert.Equal(t, "velero", crb.ObjectMeta.Name)
|
||||
assert.Equal(t, "velero", crb.Subjects[0].Namespace)
|
||||
|
||||
customNamespaceCRB := ClusterRoleBinding("foo")
|
||||
// The CRB is a cluster-scoped resource
|
||||
assert.Equal(t, "", customNamespaceCRB.ObjectMeta.Namespace)
|
||||
assert.Empty(t, customNamespaceCRB.ObjectMeta.Namespace)
|
||||
assert.Equal(t, "velero-foo", customNamespaceCRB.ObjectMeta.Name)
|
||||
assert.Equal(t, "foo", customNamespaceCRB.Subjects[0].Namespace)
|
||||
|
||||
|
||||
@@ -289,14 +289,14 @@ func TestGetResultFromJob(t *testing.T) {
|
||||
// test an error should be returned
|
||||
result, err := getResultFromJob(cli, job)
|
||||
assert.EqualError(t, err, "no pod found for job test-job")
|
||||
assert.Equal(t, "", result)
|
||||
assert.Empty(t, result)
|
||||
|
||||
cli = fake.NewClientBuilder().WithObjects(job, pod).Build()
|
||||
|
||||
// test an error should be returned
|
||||
result, err = getResultFromJob(cli, job)
|
||||
assert.EqualError(t, err, "no container statuses found for job test-job")
|
||||
assert.Equal(t, "", result)
|
||||
assert.Empty(t, result)
|
||||
|
||||
// Set a non-terminated container status to the pod
|
||||
pod.Status = corev1api.PodStatus{
|
||||
@@ -311,7 +311,7 @@ func TestGetResultFromJob(t *testing.T) {
|
||||
cli = fake.NewClientBuilder().WithObjects(job, pod).Build()
|
||||
result, err = getResultFromJob(cli, job)
|
||||
assert.EqualError(t, err, "container for job test-job is not terminated")
|
||||
assert.Equal(t, "", result)
|
||||
assert.Empty(t, result)
|
||||
|
||||
// Set a terminated container status to the pod
|
||||
pod.Status = corev1api.PodStatus{
|
||||
@@ -328,7 +328,7 @@ func TestGetResultFromJob(t *testing.T) {
|
||||
cli = fake.NewClientBuilder().WithObjects(job, pod).Build()
|
||||
result, err = getResultFromJob(cli, job)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "", result)
|
||||
assert.Empty(t, result)
|
||||
|
||||
// Set a terminated container status with invalidate message to the pod
|
||||
pod.Status = corev1api.PodStatus{
|
||||
@@ -346,7 +346,7 @@ func TestGetResultFromJob(t *testing.T) {
|
||||
cli = fake.NewClientBuilder().WithObjects(job, pod).Build()
|
||||
result, err = getResultFromJob(cli, job)
|
||||
assert.EqualError(t, err, "error to locate repo maintenance error indicator from termination message")
|
||||
assert.Equal(t, "", result)
|
||||
assert.Empty(t, result)
|
||||
|
||||
// Set a terminated container status with empty maintenance error to the pod
|
||||
pod.Status = corev1api.PodStatus{
|
||||
@@ -364,7 +364,7 @@ func TestGetResultFromJob(t *testing.T) {
|
||||
cli = fake.NewClientBuilder().WithObjects(job, pod).Build()
|
||||
result, err = getResultFromJob(cli, job)
|
||||
assert.EqualError(t, err, "nothing after repo maintenance error indicator in termination message")
|
||||
assert.Equal(t, "", result)
|
||||
assert.Empty(t, result)
|
||||
|
||||
// Set a terminated container status with maintenance error to the pod
|
||||
pod.Status = corev1api.PodStatus{
|
||||
|
||||
@@ -938,7 +938,7 @@ func TestUpdateProgress(t *testing.T) {
|
||||
if len(tc.logMessage) > 0 {
|
||||
assert.Contains(t, logMessage, tc.logMessage)
|
||||
} else {
|
||||
assert.Equal(t, "", logMessage)
|
||||
assert.Empty(t, logMessage)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -1340,7 +1340,7 @@ func TestMaintainProgress(t *testing.T) {
|
||||
if len(tc.logMessage) > 0 {
|
||||
assert.Contains(t, logMessage, tc.logMessage)
|
||||
} else {
|
||||
assert.Equal(t, "", logMessage)
|
||||
assert.Empty(t, logMessage)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ import (
|
||||
|
||||
func TestRepoName(t *testing.T) {
|
||||
c := &Command{RepoIdentifier: ""}
|
||||
assert.Equal(t, "", c.RepoName())
|
||||
assert.Empty(t, c.RepoName())
|
||||
|
||||
c.RepoIdentifier = "s3:s3.amazonaws.com/bucket/prefix/repo"
|
||||
assert.Equal(t, "repo", c.RepoName())
|
||||
|
||||
Reference in New Issue
Block a user