Skip to content

Commit

Permalink
refactor: Reformat Unit Test
Browse files Browse the repository at this point in the history
  • Loading branch information
LeelaChacha committed Oct 24, 2024
1 parent 0836eb0 commit b5c34df
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions internal/service/moduleconfig/reader/moduleconfig_reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,22 +303,19 @@ func Test_ValidateManager(t *testing.T) {
}

func Test_ValidateAssociatedResources(t *testing.T) {
type args struct {
resources []*metav1.GroupVersionKind
}
tests := []struct {
name string
args args
wantErr bool
name string
resources []*metav1.GroupVersionKind
wantErr bool
}{
{
"pass on empty resources",
args{resources: []*metav1.GroupVersionKind{}},
false,
name: "pass on empty resources",
resources: []*metav1.GroupVersionKind{},
wantErr: false,
},
{
"pass when all resources are valid",
args{resources: []*metav1.GroupVersionKind{
name: "pass when all resources are valid",
resources: []*metav1.GroupVersionKind{
{
Group: "networking.istio.io",
Version: "v1alpha3",
Expand All @@ -329,12 +326,12 @@ func Test_ValidateAssociatedResources(t *testing.T) {
Version: "v1",
Kind: "Deployment",
},
}},
false,
},
wantErr: false,
},
{
"fail when even one resources is invalid",
args{resources: []*metav1.GroupVersionKind{
name: "fail when even one resources is invalid",
resources: []*metav1.GroupVersionKind{
{
Group: "networking.istio.io",
Version: "v1alpha3",
Expand All @@ -344,13 +341,13 @@ func Test_ValidateAssociatedResources(t *testing.T) {
Group: "apps",
Kind: "Deployment",
},
}},
true,
},
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := moduleconfigreader.ValidateAssociatedResources(tt.args.resources); (err != nil) != tt.wantErr {
if err := moduleconfigreader.ValidateAssociatedResources(tt.resources); (err != nil) != tt.wantErr {
t.Errorf("ValidateAssociatedResources() error = %v, wantErr %v", err, tt.wantErr)
}
})
Expand Down

0 comments on commit b5c34df

Please sign in to comment.