From b1f01bcd0f777d520017539f78d0658bd2f34a9d Mon Sep 17 00:00:00 2001 From: Suraj Deshmukh Date: Tue, 25 Jul 2017 17:25:57 +0530 Subject: [PATCH] clean up test fixtures with test code Right now the test fixtures are in different files and each test case data is named as opposed to putting in slice so removing all those files and created a slice of test data. --- cmd/apply.go | 4 +- pkg/encoding/encoding_test.go | 152 ++++++++++++++++-- .../fixtures/multiple_ports_no_names.go | 29 ---- .../fixtures/multiple_ports_no_names_app.go | 60 ------- ...iple_ports_some_with_names_some_without.go | 31 ---- ..._ports_some_with_names_some_without_app.go | 66 -------- .../fixtures/multiple_ports_with_names.go | 31 ---- .../fixtures/multiple_ports_with_names_app.go | 60 ------- pkg/encoding/fixtures/single_container.go | 26 --- pkg/encoding/fixtures/single_container_app.go | 47 ------ .../fixtures/single_persistent_volume.go | 28 ---- .../fixtures/single_persistent_volume_app.go | 53 ------ .../fixtures/single_port_without_name.go | 26 --- .../fixtures/single_port_without_name_app.go | 47 ------ .../fixtures/single_container_object.go | 32 ---- pkg/transform/kubernetes/kubernetes_test.go | 22 ++- 16 files changed, 155 insertions(+), 559 deletions(-) delete mode 100644 pkg/encoding/fixtures/multiple_ports_no_names.go delete mode 100644 pkg/encoding/fixtures/multiple_ports_no_names_app.go delete mode 100644 pkg/encoding/fixtures/multiple_ports_some_with_names_some_without.go delete mode 100644 pkg/encoding/fixtures/multiple_ports_some_with_names_some_without_app.go delete mode 100644 pkg/encoding/fixtures/multiple_ports_with_names.go delete mode 100644 pkg/encoding/fixtures/multiple_ports_with_names_app.go delete mode 100644 pkg/encoding/fixtures/single_container.go delete mode 100644 pkg/encoding/fixtures/single_container_app.go delete mode 100644 pkg/encoding/fixtures/single_persistent_volume.go delete mode 100644 pkg/encoding/fixtures/single_persistent_volume_app.go delete mode 100644 pkg/encoding/fixtures/single_port_without_name.go delete mode 100644 pkg/encoding/fixtures/single_port_without_name_app.go delete mode 100644 pkg/transform/fixtures/single_container_object.go diff --git a/cmd/apply.go b/cmd/apply.go index a3fc66dda..c693b8499 100644 --- a/cmd/apply.go +++ b/cmd/apply.go @@ -18,9 +18,11 @@ package cmd import ( "fmt" + "os" + pkgcmd "github.com/kedgeproject/kedge/pkg/cmd" + "github.com/spf13/cobra" - "os" ) // Represents the "apply" command diff --git a/pkg/encoding/encoding_test.go b/pkg/encoding/encoding_test.go index c7f48c830..233c5e776 100644 --- a/pkg/encoding/encoding_test.go +++ b/pkg/encoding/encoding_test.go @@ -17,14 +17,13 @@ limitations under the License. package encoding import ( + "reflect" "testing" - "github.com/kedgeproject/kedge/pkg/encoding/fixtures" "github.com/kedgeproject/kedge/pkg/spec" - "reflect" - "github.com/davecgh/go-spew/spew" + api_v1 "k8s.io/client-go/pkg/api/v1" ) func TestDecode(t *testing.T) { @@ -35,36 +34,157 @@ func TestDecode(t *testing.T) { }{ { Name: "One container mentioned in the spec", - Data: fixtures.SingleContainer, - App: &fixtures.SingleContainerApp, + Data: []byte(` +name: test +containers: + - image: nginx +services: + - ports: + - port: 8080`), + App: &spec.App{ + Name: "test", + PodSpecMod: spec.PodSpecMod{ + Containers: []spec.Container{{Container: api_v1.Container{Image: "nginx"}}}, + }, + Services: []spec.ServiceSpecMod{ + {Name: "test", Ports: []spec.ServicePortMod{{ServicePort: api_v1.ServicePort{Port: 8080}}}}, + }, + }, }, { Name: "One persistent volume mentioned in the spec", - Data: fixtures.SinglePersistentVolume, - App: &fixtures.SinglePersistentVolumeApp, + Data: []byte(` +name: test +containers: + - image: nginx +services: + - ports: + - port: 8080 +volumeClaims: +- size: 500Mi`), + App: &spec.App{ + Name: "test", + PodSpecMod: spec.PodSpecMod{ + Containers: []spec.Container{{Container: api_v1.Container{Image: "nginx"}}}, + }, + Services: []spec.ServiceSpecMod{ + {Name: "test", Ports: []spec.ServicePortMod{{ServicePort: api_v1.ServicePort{Port: 8080}}}}, + }, + VolumeClaims: []spec.VolumeClaim{{Name: "test", Size: "500Mi"}}, + }, }, { Name: "Multiple ports specified with any names", - Data: fixtures.MultiplePortsNoNames, - App: &fixtures.MultiplePortsNoNamesApp, + Data: []byte(` +name: test +containers: + - image: nginx +services: +- name: nginx + ports: + - port: 8080 + - port: 8081 + - port: 8082`), + App: &spec.App{ + Name: "test", + PodSpecMod: spec.PodSpecMod{ + Containers: []spec.Container{{Container: api_v1.Container{Image: "nginx"}}}, + }, + Services: []spec.ServiceSpecMod{ + { + Name: "nginx", + Ports: []spec.ServicePortMod{ + {ServicePort: api_v1.ServicePort{Port: 8080, Name: "nginx-8080"}}, + {ServicePort: api_v1.ServicePort{Port: 8081, Name: "nginx-8081"}}, + {ServicePort: api_v1.ServicePort{Port: 8082, Name: "nginx-8082"}}, + }, + }, + }, + }, }, { Name: "Multiple ports, some with names specified, others with no names", - Data: fixtures.MultiplePortsWithAndWithoutNames, - App: &fixtures.MultiplePortsWithAndWithoutNamesApp, + Data: []byte(` +name: test +containers: + - image: nginx +services: +- ports: + - port: 8080 + name: port-1 + - port: 8081 + name: port-2 + - port: 8082 + - port: 8083`), + App: &spec.App{ + Name: "test", + PodSpecMod: spec.PodSpecMod{ + Containers: []spec.Container{{Container: api_v1.Container{Image: "nginx"}}}, + }, + Services: []spec.ServiceSpecMod{ + { + Name: "test", + Ports: []spec.ServicePortMod{ + {ServicePort: api_v1.ServicePort{Port: 8080, Name: "port-1"}}, + {ServicePort: api_v1.ServicePort{Port: 8081, Name: "port-2"}}, + {ServicePort: api_v1.ServicePort{Port: 8082, Name: "test-8082"}}, + {ServicePort: api_v1.ServicePort{Port: 8083, Name: "test-8083"}}, + }, + }, + }, + }, }, { Name: "Multiple ports, all with names", - Data: fixtures.MultiplePortsWithNames, - App: &fixtures.MultiplePortsWithNamesApp, + Data: []byte(` +name: test +containers: + - image: nginx +services: +- ports: + - port: 8080 + name: port-1 + - port: 8081 + name: port-2 + - port: 8082 + name: port-3`), + App: &spec.App{ + Name: "test", + PodSpecMod: spec.PodSpecMod{ + Containers: []spec.Container{{Container: api_v1.Container{Image: "nginx"}}}, + }, + Services: []spec.ServiceSpecMod{ + { + Name: "test", + Ports: []spec.ServicePortMod{ + {ServicePort: api_v1.ServicePort{Port: 8080, Name: "port-1"}}, + {ServicePort: api_v1.ServicePort{Port: 8081, Name: "port-2"}}, + {ServicePort: api_v1.ServicePort{Port: 8082, Name: "port-3"}}, + }, + }, + }, + }, }, { Name: "Single port, without any name", - Data: fixtures.SinglePortWithoutName, - App: &fixtures.SinglePortWithoutNameApp, + Data: []byte(` +name: test +containers: + - image: nginx +services: +- ports: + - port: 8080`), + App: &spec.App{ + Name: "test", + PodSpecMod: spec.PodSpecMod{ + Containers: []spec.Container{{Container: api_v1.Container{Image: "nginx"}}}, + }, + Services: []spec.ServiceSpecMod{ + {Name: "test", Ports: []spec.ServicePortMod{{ServicePort: api_v1.ServicePort{Port: 8080}}}}, + }, + }, }, } - for _, test := range tests { t.Run(test.Name, func(t *testing.T) { app, err := Decode(test.Data) diff --git a/pkg/encoding/fixtures/multiple_ports_no_names.go b/pkg/encoding/fixtures/multiple_ports_no_names.go deleted file mode 100644 index ec18ac159..000000000 --- a/pkg/encoding/fixtures/multiple_ports_no_names.go +++ /dev/null @@ -1,29 +0,0 @@ -/* -Copyright 2017 The Kedge Authors All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package fixtures - -var MultiplePortsNoNames []byte = []byte( - `name: test -containers: - - image: nginx -services: -- name: nginx - ports: - - port: 8080 - - port: 8081 - - port: 8082 -`) diff --git a/pkg/encoding/fixtures/multiple_ports_no_names_app.go b/pkg/encoding/fixtures/multiple_ports_no_names_app.go deleted file mode 100644 index 491c3baad..000000000 --- a/pkg/encoding/fixtures/multiple_ports_no_names_app.go +++ /dev/null @@ -1,60 +0,0 @@ -/* -Copyright 2017 The Kedge Authors All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package fixtures - -import ( - "github.com/kedgeproject/kedge/pkg/spec" - api_v1 "k8s.io/client-go/pkg/api/v1" -) - -var MultiplePortsNoNamesApp spec.App = spec.App{ - Name: "test", - PodSpecMod: spec.PodSpecMod{ - Containers: []spec.Container{ - { - Container: api_v1.Container{ - Image: "nginx", - }, - }, - }, - }, - Services: []spec.ServiceSpecMod{ - { - Name: "nginx", - Ports: []spec.ServicePortMod{ - { - ServicePort: api_v1.ServicePort{ - Port: 8080, - Name: "nginx-8080", - }, - }, - { - ServicePort: api_v1.ServicePort{ - Port: 8081, - Name: "nginx-8081", - }, - }, - { - ServicePort: api_v1.ServicePort{ - Port: 8082, - Name: "nginx-8082", - }, - }, - }, - }, - }, -} diff --git a/pkg/encoding/fixtures/multiple_ports_some_with_names_some_without.go b/pkg/encoding/fixtures/multiple_ports_some_with_names_some_without.go deleted file mode 100644 index 430d8a9d4..000000000 --- a/pkg/encoding/fixtures/multiple_ports_some_with_names_some_without.go +++ /dev/null @@ -1,31 +0,0 @@ -/* -Copyright 2017 The Kedge Authors All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package fixtures - -var MultiplePortsWithAndWithoutNames []byte = []byte( - `name: test -containers: - - image: nginx -services: -- ports: - - port: 8080 - name: port-1 - - port: 8081 - name: port-2 - - port: 8082 - - port: 8083 -`) diff --git a/pkg/encoding/fixtures/multiple_ports_some_with_names_some_without_app.go b/pkg/encoding/fixtures/multiple_ports_some_with_names_some_without_app.go deleted file mode 100644 index f4984913f..000000000 --- a/pkg/encoding/fixtures/multiple_ports_some_with_names_some_without_app.go +++ /dev/null @@ -1,66 +0,0 @@ -/* -Copyright 2017 The Kedge Authors All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package fixtures - -import ( - "github.com/kedgeproject/kedge/pkg/spec" - api_v1 "k8s.io/client-go/pkg/api/v1" -) - -var MultiplePortsWithAndWithoutNamesApp spec.App = spec.App{ - Name: "test", - PodSpecMod: spec.PodSpecMod{ - Containers: []spec.Container{ - { - Container: api_v1.Container{ - Image: "nginx", - }, - }, - }, - }, - Services: []spec.ServiceSpecMod{ - { - Name: "test", - Ports: []spec.ServicePortMod{ - { - ServicePort: api_v1.ServicePort{ - Port: 8080, - Name: "port-1", - }, - }, - { - ServicePort: api_v1.ServicePort{ - Port: 8081, - Name: "port-2", - }, - }, - { - ServicePort: api_v1.ServicePort{ - Port: 8082, - Name: "test-8082", - }, - }, - { - ServicePort: api_v1.ServicePort{ - Port: 8083, - Name: "test-8083", - }, - }, - }, - }, - }, -} diff --git a/pkg/encoding/fixtures/multiple_ports_with_names.go b/pkg/encoding/fixtures/multiple_ports_with_names.go deleted file mode 100644 index 439f25832..000000000 --- a/pkg/encoding/fixtures/multiple_ports_with_names.go +++ /dev/null @@ -1,31 +0,0 @@ -/* -Copyright 2017 The Kedge Authors All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package fixtures - -var MultiplePortsWithNames []byte = []byte( - `name: test -containers: - - image: nginx -services: -- ports: - - port: 8080 - name: port-1 - - port: 8081 - name: port-2 - - port: 8082 - name: port-3 -`) diff --git a/pkg/encoding/fixtures/multiple_ports_with_names_app.go b/pkg/encoding/fixtures/multiple_ports_with_names_app.go deleted file mode 100644 index ac098cdfb..000000000 --- a/pkg/encoding/fixtures/multiple_ports_with_names_app.go +++ /dev/null @@ -1,60 +0,0 @@ -/* -Copyright 2017 The Kedge Authors All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package fixtures - -import ( - "github.com/kedgeproject/kedge/pkg/spec" - api_v1 "k8s.io/client-go/pkg/api/v1" -) - -var MultiplePortsWithNamesApp spec.App = spec.App{ - Name: "test", - PodSpecMod: spec.PodSpecMod{ - Containers: []spec.Container{ - { - Container: api_v1.Container{ - Image: "nginx", - }, - }, - }, - }, - Services: []spec.ServiceSpecMod{ - { - Name: "test", - Ports: []spec.ServicePortMod{ - { - ServicePort: api_v1.ServicePort{ - Port: 8080, - Name: "port-1", - }, - }, - { - ServicePort: api_v1.ServicePort{ - Port: 8081, - Name: "port-2", - }, - }, - { - ServicePort: api_v1.ServicePort{ - Port: 8082, - Name: "port-3", - }, - }, - }, - }, - }, -} diff --git a/pkg/encoding/fixtures/single_container.go b/pkg/encoding/fixtures/single_container.go deleted file mode 100644 index 010510f6f..000000000 --- a/pkg/encoding/fixtures/single_container.go +++ /dev/null @@ -1,26 +0,0 @@ -/* -Copyright 2017 The Kedge Authors All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package fixtures - -var SingleContainer []byte = []byte( - `name: test -containers: - - image: nginx -services: - - ports: - - port: 8080 -`) diff --git a/pkg/encoding/fixtures/single_container_app.go b/pkg/encoding/fixtures/single_container_app.go deleted file mode 100644 index 701a77aee..000000000 --- a/pkg/encoding/fixtures/single_container_app.go +++ /dev/null @@ -1,47 +0,0 @@ -/* -Copyright 2017 The Kedge Authors All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package fixtures - -import ( - "github.com/kedgeproject/kedge/pkg/spec" - api_v1 "k8s.io/client-go/pkg/api/v1" -) - -var SingleContainerApp spec.App = spec.App{ - Name: "test", - PodSpecMod: spec.PodSpecMod{ - Containers: []spec.Container{ - { - Container: api_v1.Container{ - Image: "nginx", - }, - }, - }, - }, - Services: []spec.ServiceSpecMod{ - { - Name: "test", - Ports: []spec.ServicePortMod{ - { - ServicePort: api_v1.ServicePort{ - Port: 8080, - }, - }, - }, - }, - }, -} diff --git a/pkg/encoding/fixtures/single_persistent_volume.go b/pkg/encoding/fixtures/single_persistent_volume.go deleted file mode 100644 index 40d05b208..000000000 --- a/pkg/encoding/fixtures/single_persistent_volume.go +++ /dev/null @@ -1,28 +0,0 @@ -/* -Copyright 2017 The Kedge Authors All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package fixtures - -var SinglePersistentVolume []byte = []byte( - `name: test -containers: - - image: nginx -services: - - ports: - - port: 8080 -volumeClaims: -- size: 500Mi -`) diff --git a/pkg/encoding/fixtures/single_persistent_volume_app.go b/pkg/encoding/fixtures/single_persistent_volume_app.go deleted file mode 100644 index 72a9b2cd8..000000000 --- a/pkg/encoding/fixtures/single_persistent_volume_app.go +++ /dev/null @@ -1,53 +0,0 @@ -/* -Copyright 2017 The Kedge Authors All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package fixtures - -import ( - "github.com/kedgeproject/kedge/pkg/spec" - api_v1 "k8s.io/client-go/pkg/api/v1" -) - -var SinglePersistentVolumeApp spec.App = spec.App{ - Name: "test", - PodSpecMod: spec.PodSpecMod{ - Containers: []spec.Container{ - { - Container: api_v1.Container{ - Image: "nginx", - }, - }, - }, - }, - Services: []spec.ServiceSpecMod{ - { - Name: "test", - Ports: []spec.ServicePortMod{ - { - ServicePort: api_v1.ServicePort{ - Port: 8080, - }, - }, - }, - }, - }, - VolumeClaims: []spec.VolumeClaim{ - { - Name: "test", - Size: "500Mi", - }, - }, -} diff --git a/pkg/encoding/fixtures/single_port_without_name.go b/pkg/encoding/fixtures/single_port_without_name.go deleted file mode 100644 index 98200353b..000000000 --- a/pkg/encoding/fixtures/single_port_without_name.go +++ /dev/null @@ -1,26 +0,0 @@ -/* -Copyright 2017 The Kedge Authors All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package fixtures - -var SinglePortWithoutName []byte = []byte( - `name: test -containers: - - image: nginx -services: -- ports: - - port: 8080 -`) diff --git a/pkg/encoding/fixtures/single_port_without_name_app.go b/pkg/encoding/fixtures/single_port_without_name_app.go deleted file mode 100644 index 8488a3eb6..000000000 --- a/pkg/encoding/fixtures/single_port_without_name_app.go +++ /dev/null @@ -1,47 +0,0 @@ -/* -Copyright 2017 The Kedge Authors All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package fixtures - -import ( - "github.com/kedgeproject/kedge/pkg/spec" - api_v1 "k8s.io/client-go/pkg/api/v1" -) - -var SinglePortWithoutNameApp spec.App = spec.App{ - Name: "test", - PodSpecMod: spec.PodSpecMod{ - Containers: []spec.Container{ - { - Container: api_v1.Container{ - Image: "nginx", - }, - }, - }, - }, - Services: []spec.ServiceSpecMod{ - { - Name: "test", - Ports: []spec.ServicePortMod{ - { - ServicePort: api_v1.ServicePort{ - Port: 8080, - }, - }, - }, - }, - }, -} diff --git a/pkg/transform/fixtures/single_container_object.go b/pkg/transform/fixtures/single_container_object.go deleted file mode 100644 index 96b746a70..000000000 --- a/pkg/transform/fixtures/single_container_object.go +++ /dev/null @@ -1,32 +0,0 @@ -/* -Copyright 2017 The Kedge Authors All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package fixtures - -import api_v1 "k8s.io/client-go/pkg/api/v1" - -var SingleContainerService *api_v1.Service = &api_v1.Service{ - ObjectMeta: api_v1.ObjectMeta{ - Name: "test", - }, - Spec: api_v1.ServiceSpec{ - Ports: []api_v1.ServicePort{ - { - Port: 8080, - }, - }, - }, -} diff --git a/pkg/transform/kubernetes/kubernetes_test.go b/pkg/transform/kubernetes/kubernetes_test.go index c1a6478b8..969a9212c 100644 --- a/pkg/transform/kubernetes/kubernetes_test.go +++ b/pkg/transform/kubernetes/kubernetes_test.go @@ -17,13 +17,12 @@ limitations under the License. package kubernetes import ( - "testing" - "reflect" + "testing" - encodingFixtures "github.com/kedgeproject/kedge/pkg/encoding/fixtures" "github.com/kedgeproject/kedge/pkg/spec" - transformFixtures "github.com/kedgeproject/kedge/pkg/transform/fixtures" + + api_v1 "k8s.io/client-go/pkg/api/v1" "k8s.io/client-go/pkg/runtime" ) @@ -35,8 +34,19 @@ func TestCreateServices(t *testing.T) { }{ { "Single container specified", - &encodingFixtures.SingleContainerApp, - append(make([]runtime.Object, 0), transformFixtures.SingleContainerService), + &spec.App{ + Name: "test", + PodSpecMod: spec.PodSpecMod{ + Containers: []spec.Container{{Container: api_v1.Container{Image: "nginx"}}}, + }, + Services: []spec.ServiceSpecMod{ + {Name: "test", Ports: []spec.ServicePortMod{{ServicePort: api_v1.ServicePort{Port: 8080}}}}, + }, + }, + append(make([]runtime.Object, 0), &api_v1.Service{ + ObjectMeta: api_v1.ObjectMeta{Name: "test"}, + Spec: api_v1.ServiceSpec{Ports: []api_v1.ServicePort{{Port: 8080}}}, + }), }, }