Skip to content

Commit

Permalink
style: fix intendation
Browse files Browse the repository at this point in the history
Signed-off-by: Shubham Gupta <iamshubhamgupta2001@gmail.com>
  • Loading branch information
shubham-cmyk committed Feb 19, 2024
1 parent 48cd0a4 commit a09c441
Showing 1 changed file with 126 additions and 140 deletions.
266 changes: 126 additions & 140 deletions pkg/runner/kubectl/describe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,158 +14,144 @@ func TestDescribe(t *testing.T) {
collector *v1alpha1.Describe
want *v1alpha1.Command
wantErr bool
}{
{
name: "nil",
collector: nil,
want: nil,
wantErr: false,
},
{
name: "empty",
collector: &v1alpha1.Describe{},
wantErr: true,
},
{
name: "without resource",
collector: &v1alpha1.Describe{
ObjectLabelsSelector: v1alpha1.ObjectLabelsSelector{
Name: "foo",
},
}{{
name: "nil",
collector: nil,
want: nil,
wantErr: false,
}, {
name: "empty",
collector: &v1alpha1.Describe{},
wantErr: true,
}, {
name: "without resource",
collector: &v1alpha1.Describe{
ObjectLabelsSelector: v1alpha1.ObjectLabelsSelector{
Name: "foo",
},
wantErr: true,
},
{
name: "with resource",
collector: &v1alpha1.Describe{
Resource: "foos",
},
want: &v1alpha1.Command{
Entrypoint: "kubectl",
Args: []string{"describe", "foos", "-n", "$NAMESPACE"},
},
wantErr: false,
},
{
name: "with name",
collector: &v1alpha1.Describe{
Resource: "foos",
ObjectLabelsSelector: v1alpha1.ObjectLabelsSelector{
Name: "foo",
},
},
want: &v1alpha1.Command{
Entrypoint: "kubectl",
Args: []string{"describe", "foos", "foo", "-n", "$NAMESPACE"},
},
wantErr: false,
},
{
name: "with namespace",
collector: &v1alpha1.Describe{
Resource: "foos",
ObjectLabelsSelector: v1alpha1.ObjectLabelsSelector{
Namespace: "bar",
},
},
want: &v1alpha1.Command{
Entrypoint: "kubectl",
Args: []string{"describe", "foos", "-n", "bar"},
},
wantErr: false,
},
{
name: "with name and namespace",
collector: &v1alpha1.Describe{
Resource: "foos",
ObjectLabelsSelector: v1alpha1.ObjectLabelsSelector{
Name: "foo",
Namespace: "bar",
},
},
want: &v1alpha1.Command{
Entrypoint: "kubectl",
Args: []string{"describe", "foos", "foo", "-n", "bar"},
},
wantErr: false,
wantErr: true,
}, {
name: "with resource",
collector: &v1alpha1.Describe{
Resource: "foos",
},
{
name: "without name and selector",
collector: &v1alpha1.Describe{
Resource: "foos",
ObjectLabelsSelector: v1alpha1.ObjectLabelsSelector{},
},
want: &v1alpha1.Command{
Entrypoint: "kubectl",
Args: []string{"describe", "foos", "-n", "$NAMESPACE"},
},
wantErr: false,
},
{
name: "with selector",
collector: &v1alpha1.Describe{
Resource: "foos",
ObjectLabelsSelector: v1alpha1.ObjectLabelsSelector{
Selector: "foo=bar",
},
},
want: &v1alpha1.Command{
Entrypoint: "kubectl",
Args: []string{"describe", "foos", "-l", "foo=bar", "-n", "$NAMESPACE"},
},
wantErr: false,
},
{
name: "with name and selector",
collector: &v1alpha1.Describe{
Resource: "foos",
ObjectLabelsSelector: v1alpha1.ObjectLabelsSelector{
Name: "foo",
Selector: "foo=bar",
},
},
wantErr: true,
},
{
name: "with namespace and selector",
collector: &v1alpha1.Describe{
Resource: "foos",
ObjectLabelsSelector: v1alpha1.ObjectLabelsSelector{
Namespace: "bar",
Selector: "foo=bar",
},
want: &v1alpha1.Command{
Entrypoint: "kubectl",
Args: []string{"describe", "foos", "-n", "$NAMESPACE"},
},
wantErr: false,
}, {
name: "with name",
collector: &v1alpha1.Describe{
Resource: "foos",
ObjectLabelsSelector: v1alpha1.ObjectLabelsSelector{
Name: "foo",
},
want: &v1alpha1.Command{
Entrypoint: "kubectl",
Args: []string{"describe", "foos", "-l", "foo=bar", "-n", "bar"},
},
want: &v1alpha1.Command{
Entrypoint: "kubectl",
Args: []string{"describe", "foos", "foo", "-n", "$NAMESPACE"},
},
wantErr: false,
}, {
name: "with namespace",
collector: &v1alpha1.Describe{
Resource: "foos",
ObjectLabelsSelector: v1alpha1.ObjectLabelsSelector{
Namespace: "bar",
},
wantErr: false,
},
{
name: "with show-events marked as true",
collector: &v1alpha1.Describe{
Resource: "foos",
ShowEvents: ptr.To[bool](true),
want: &v1alpha1.Command{
Entrypoint: "kubectl",
Args: []string{"describe", "foos", "-n", "bar"},
},
wantErr: false,
}, {
name: "with name and namespace",
collector: &v1alpha1.Describe{
Resource: "foos",
ObjectLabelsSelector: v1alpha1.ObjectLabelsSelector{
Name: "foo",
Namespace: "bar",
},
want: &v1alpha1.Command{
Entrypoint: "kubectl",
Args: []string{"describe", "foos", "-n", "$NAMESPACE", "--show-events=true"},
},
want: &v1alpha1.Command{
Entrypoint: "kubectl",
Args: []string{"describe", "foos", "foo", "-n", "bar"},
},
wantErr: false,
}, {
name: "without name and selector",
collector: &v1alpha1.Describe{
Resource: "foos",
ObjectLabelsSelector: v1alpha1.ObjectLabelsSelector{},
},
want: &v1alpha1.Command{
Entrypoint: "kubectl",
Args: []string{"describe", "foos", "-n", "$NAMESPACE"},
},
wantErr: false,
}, {
name: "with selector",
collector: &v1alpha1.Describe{
Resource: "foos",
ObjectLabelsSelector: v1alpha1.ObjectLabelsSelector{
Selector: "foo=bar",
},
wantErr: false,
},
{
name: "with show-events marked as false",
collector: &v1alpha1.Describe{
Resource: "foos",
ShowEvents: ptr.To[bool](false),
want: &v1alpha1.Command{
Entrypoint: "kubectl",
Args: []string{"describe", "foos", "-l", "foo=bar", "-n", "$NAMESPACE"},
},
wantErr: false,
}, {
name: "with name and selector",
collector: &v1alpha1.Describe{
Resource: "foos",
ObjectLabelsSelector: v1alpha1.ObjectLabelsSelector{
Name: "foo",
Selector: "foo=bar",
},
want: &v1alpha1.Command{
Entrypoint: "kubectl",
Args: []string{"describe", "foos", "-n", "$NAMESPACE", "--show-events=false"},
},
wantErr: true,
}, {
name: "with namespace and selector",
collector: &v1alpha1.Describe{
Resource: "foos",
ObjectLabelsSelector: v1alpha1.ObjectLabelsSelector{
Namespace: "bar",
Selector: "foo=bar",
},
wantErr: false,
},
}
want: &v1alpha1.Command{
Entrypoint: "kubectl",
Args: []string{"describe", "foos", "-l", "foo=bar", "-n", "bar"},
},
wantErr: false,
}, {
name: "with show-events marked as true",
collector: &v1alpha1.Describe{
Resource: "foos",
ShowEvents: ptr.To[bool](true),
},
want: &v1alpha1.Command{
Entrypoint: "kubectl",
Args: []string{"describe", "foos", "-n", "$NAMESPACE", "--show-events=true"},
},
wantErr: false,
}, {
name: "with show-events marked as false",
collector: &v1alpha1.Describe{
Resource: "foos",
ShowEvents: ptr.To[bool](false),
},
want: &v1alpha1.Command{
Entrypoint: "kubectl",
Args: []string{"describe", "foos", "-n", "$NAMESPACE", "--show-events=false"},
},
wantErr: false,
}}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := Describe(tt.collector)
Expand Down

0 comments on commit a09c441

Please sign in to comment.