Skip to content

Commit 5335c56

Browse files
committed
removed testify tests and mocks
1 parent 879b250 commit 5335c56

File tree

5 files changed

+3
-649
lines changed

5 files changed

+3
-649
lines changed

pkg/component/component_test.go

Lines changed: 3 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@ package component
33
import (
44
"fmt"
55
"io/ioutil"
6-
v1 "k8s.io/api/apps/v1"
76
"os"
87
"path/filepath"
98
"reflect"
109
"regexp"
1110
"sort"
1211
"testing"
1312

13+
v1 "k8s.io/api/apps/v1"
14+
1415
"github.com/openshift/odo/pkg/util"
1516

1617
"github.com/golang/mock/gomock"
1718
applabels "github.com/openshift/odo/pkg/application/labels"
1819
componentlabels "github.com/openshift/odo/pkg/component/labels"
1920
"github.com/openshift/odo/pkg/config"
2021
"github.com/openshift/odo/pkg/envinfo"
21-
"github.com/openshift/odo/pkg/envinfo/mocks"
2222
"github.com/openshift/odo/pkg/occlient"
2323
"github.com/openshift/odo/pkg/testingutil"
2424

@@ -33,7 +33,7 @@ import (
3333
. "github.com/openshift/odo/pkg/config"
3434
)
3535

36-
func TestGomockGetComponentFrom(t *testing.T) {
36+
func TestGetComponentFrom(t *testing.T) {
3737
type cmpSetting struct {
3838
componentName string
3939
project string
@@ -145,117 +145,6 @@ func TestGomockGetComponentFrom(t *testing.T) {
145145
}
146146
}
147147

148-
func TestTestifyGetComponentFrom(t *testing.T) {
149-
type cmpSetting struct {
150-
componentName string
151-
project string
152-
applicationName string
153-
debugPort int
154-
}
155-
tests := []struct {
156-
name string
157-
isEnvInfo bool
158-
componentType string
159-
envURL []envinfo.EnvInfoURL
160-
cmpSetting cmpSetting
161-
want Component
162-
}{
163-
{
164-
name: "Case 1: Get component when env info file exists",
165-
isEnvInfo: true,
166-
componentType: "nodejs",
167-
envURL: []envinfo.EnvInfoURL{
168-
{
169-
Name: "url1",
170-
},
171-
},
172-
cmpSetting: cmpSetting{
173-
componentName: "frontend",
174-
project: "project1",
175-
applicationName: "testing",
176-
debugPort: 1234,
177-
},
178-
want: Component{
179-
TypeMeta: metav1.TypeMeta{
180-
Kind: "Component",
181-
APIVersion: "odo.dev/v1alpha1",
182-
},
183-
ObjectMeta: metav1.ObjectMeta{
184-
Name: "frontend",
185-
},
186-
Spec: ComponentSpec{
187-
Type: "nodejs",
188-
},
189-
Status: ComponentStatus{},
190-
},
191-
},
192-
193-
{
194-
name: "Case 2: Get component when env info file does not exists",
195-
isEnvInfo: false,
196-
componentType: "nodejs",
197-
envURL: []envinfo.EnvInfoURL{
198-
{
199-
Name: "url2",
200-
},
201-
},
202-
cmpSetting: cmpSetting{
203-
componentName: "backend",
204-
project: "project2",
205-
applicationName: "app1",
206-
debugPort: 5896,
207-
},
208-
want: Component{},
209-
},
210-
}
211-
212-
for _, tt := range tests {
213-
t.Run(tt.name, func(t *testing.T) {
214-
215-
mockLocalConfig := &mocks.LocalConfigProvider{}
216-
217-
mockLocalConfig.On("Exists").Return(tt.isEnvInfo)
218-
219-
if tt.isEnvInfo {
220-
mockLocalConfig.On("GetName").Return(tt.cmpSetting.componentName)
221-
222-
component := getMachineReadableFormat(tt.cmpSetting.componentName, tt.componentType)
223-
224-
mockLocalConfig.On("GetNamespace").Return(tt.cmpSetting.project)
225-
226-
component.Namespace = tt.cmpSetting.project
227-
mockLocalConfig.On("GetApplication").Return(tt.cmpSetting.applicationName)
228-
mockLocalConfig.On("GetDebugPort").Return(tt.cmpSetting.debugPort)
229-
230-
component.Spec = ComponentSpec{
231-
App: tt.cmpSetting.applicationName,
232-
Type: tt.componentType,
233-
Ports: []string{fmt.Sprintf("%d", tt.cmpSetting.debugPort)},
234-
}
235-
236-
mockLocalConfig.On("GetURL").Return(tt.envURL)
237-
238-
if len(tt.envURL) > 0 {
239-
for _, url := range tt.envURL {
240-
component.Spec.URL = append(component.Spec.URL, url.Name)
241-
}
242-
}
243-
244-
tt.want = component
245-
246-
}
247-
248-
got := getComponentFrom(mockLocalConfig, tt.componentType)
249-
if !reflect.DeepEqual(got, tt.want) {
250-
t.Errorf("getComponentFrom() = %v, want %v", got, tt.want)
251-
}
252-
253-
mockLocalConfig.AssertExpectations(t)
254-
255-
})
256-
}
257-
}
258-
259148
func TestGetS2IPaths(t *testing.T) {
260149

261150
tests := []struct {

pkg/devfile/adapters/common/mock/InterfaceMock.go

Lines changed: 0 additions & 218 deletions
This file was deleted.

0 commit comments

Comments
 (0)