Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 29 additions & 14 deletions source/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,17 +195,16 @@ func (suite *ByNamesTestSuite) TestKubeClientFails() {
mockClientGenerator := new(MockClientGenerator)
mockClientGenerator.On("KubeClient").Return(nil, errors.New("foo"))

_, err := ByNames(context.TODO(), mockClientGenerator, []string{"service"}, &Config{})
suite.Error(err, "should return an error if kubernetes client cannot be created")

_, err = ByNames(context.TODO(), mockClientGenerator, []string{"ingress"}, &Config{})
suite.Error(err, "should return an error if kubernetes client cannot be created")

_, err = ByNames(context.TODO(), mockClientGenerator, []string{"istio-gateway"}, &Config{})
suite.Error(err, "should return an error if kubernetes client cannot be created")
sourcesDependentOnKubeClient := []string{
"node", "service", "ingress", "pod", "istio-gateway", "istio-virtualservice",
"ambassador-host", "gloo-proxy", "traefik-proxy", "crd", "kong-tcpingress",
"f5-virtualserver", "f5-transportserver",
}

_, err = ByNames(context.TODO(), mockClientGenerator, []string{"kong-tcpingress"}, &Config{})
suite.Error(err, "should return an error if kubernetes client cannot be created")
for _, source := range sourcesDependentOnKubeClient {
_, err := ByNames(context.TODO(), mockClientGenerator, []string{source}, &Config{})
suite.Error(err, source+" should return an error if kubernetes client cannot be created")
}
}

func (suite *ByNamesTestSuite) TestIstioClientFails() {
Expand All @@ -214,11 +213,27 @@ func (suite *ByNamesTestSuite) TestIstioClientFails() {
mockClientGenerator.On("IstioClient").Return(nil, errors.New("foo"))
mockClientGenerator.On("DynamicKubernetesClient").Return(nil, errors.New("foo"))

_, err := ByNames(context.TODO(), mockClientGenerator, []string{"istio-gateway"}, &Config{})
suite.Error(err, "should return an error if istio client cannot be created")
sourcesDependentOnIstioClient := []string{"istio-gateway", "istio-virtualservice"}

for _, source := range sourcesDependentOnIstioClient {
_, err := ByNames(context.TODO(), mockClientGenerator, []string{source}, &Config{})
suite.Error(err, source+" should return an error if istio client cannot be created")
}
}

func (suite *ByNamesTestSuite) TestDynamicKubernetesClientFails() {
mockClientGenerator := new(MockClientGenerator)
mockClientGenerator.On("KubeClient").Return(fakeKube.NewSimpleClientset(), nil)
mockClientGenerator.On("IstioClient").Return(istiofake.NewSimpleClientset(), nil)
mockClientGenerator.On("DynamicKubernetesClient").Return(nil, errors.New("foo"))

sourcesDependentOnDynamicKubernetesClient := []string{"ambassador-host", "contour-httpproxy", "gloo-proxy", "traefik-proxy",
"kong-tcpingress", "f5-virtualserver", "f5-transportserver"}

_, err = ByNames(context.TODO(), mockClientGenerator, []string{"contour-httpproxy"}, &Config{})
suite.Error(err, "should return an error if contour client cannot be created")
for _, source := range sourcesDependentOnDynamicKubernetesClient {
_, err := ByNames(context.TODO(), mockClientGenerator, []string{source}, &Config{})
suite.Error(err, source+" should return an error if dynamic kubernetes client cannot be created")
}
}

func TestByNames(t *testing.T) {
Expand Down
Loading