Skip to content

Commit

Permalink
fix: test
Browse files Browse the repository at this point in the history
Signed-off-by: Fernando Cainelli <[email protected]>
  • Loading branch information
cainelli committed Sep 23, 2024
1 parent 51356eb commit 011a238
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
8 changes: 4 additions & 4 deletions examples/multidocument_virtualservice.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: example
namespace: example
name: example-2
namespace: example-2
spec:
gateways:
- mesh
Expand All @@ -26,8 +26,8 @@ spec:
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: example
namespace: example
name: example-3
namespace: example-3
spec:
gateways:
- mesh
Expand Down
13 changes: 6 additions & 7 deletions internal/pkg/parser/virtualservice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,20 @@ func TestParseVirtualServices(t *testing.T) {
}

func TestParseMultipleVirtualServices(t *testing.T) {
expectedTestCases := []*v1alpha3.VirtualService{{Spec: networkingv1alpha3.VirtualService{
Hosts: []string{"www.example.com", "example.com"},
}}}
wantHosts := []string{"www.example2.com", "example2.com", "www.example3.com", "example3.com"}

configfiles := []string{"../../../examples/multidocument_virtualservice.yml"}
virtualServices, err := ParseVirtualServices(configfiles)
require.NoError(t, err)
require.NotEmpty(t, virtualServices)
require.GreaterOrEqual(t, len(virtualServices), 2)

for _, expected := range expectedTestCases {
for _, out := range virtualServices {
assert.ElementsMatch(t, expected.Spec.Hosts, out.Spec.Hosts)
}
var gotHosts []string
for _, vs := range virtualServices {
gotHosts = append(gotHosts, vs.Spec.Hosts...)
}
require.ElementsMatch(t, wantHosts, gotHosts)

}

func TestVirtualServiceUnknownFields(t *testing.T) {
Expand Down

0 comments on commit 011a238

Please sign in to comment.