Skip to content

Commit

Permalink
refactor: Indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
LeelaChacha committed Oct 24, 2024
1 parent de6b4d3 commit 0836eb0
Showing 1 changed file with 55 additions and 43 deletions.
98 changes: 55 additions & 43 deletions internal/service/moduleconfig/reader/moduleconfig_reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,61 @@ 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
}{
{
"pass on empty resources",
args{resources: []*metav1.GroupVersionKind{}},
false,
},
{
"pass when all resources are valid",
args{resources: []*metav1.GroupVersionKind{
{
Group: "networking.istio.io",
Version: "v1alpha3",
Kind: "Gateway",
},
{
Group: "apps",
Version: "v1",
Kind: "Deployment",
},
}},
false,
},
{
"fail when even one resources is invalid",
args{resources: []*metav1.GroupVersionKind{
{
Group: "networking.istio.io",
Version: "v1alpha3",
Kind: "Gateway",
},
{
Group: "apps",
Kind: "Deployment",
},
}},
true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := moduleconfigreader.ValidateAssociatedResources(tt.args.resources); (err != nil) != tt.wantErr {
t.Errorf("ValidateAssociatedResources() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}

// Test Stubs

type fileExistsStub struct{}
Expand Down Expand Up @@ -345,49 +400,6 @@ var expectedReturnedModuleConfig = contentprovider.ModuleConfig{
},
}

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

func (*fileExistsStub) ReadFile(_ string) ([]byte, error) {
return yaml.Marshal(expectedReturnedModuleConfig)
}
Expand Down

0 comments on commit 0836eb0

Please sign in to comment.