@@ -3,22 +3,22 @@ package component
3
3
import (
4
4
"fmt"
5
5
"io/ioutil"
6
- v1 "k8s.io/api/apps/v1"
7
6
"os"
8
7
"path/filepath"
9
8
"reflect"
10
9
"regexp"
11
10
"sort"
12
11
"testing"
13
12
13
+ v1 "k8s.io/api/apps/v1"
14
+
14
15
"github.com/openshift/odo/pkg/util"
15
16
16
17
"github.com/golang/mock/gomock"
17
18
applabels "github.com/openshift/odo/pkg/application/labels"
18
19
componentlabels "github.com/openshift/odo/pkg/component/labels"
19
20
"github.com/openshift/odo/pkg/config"
20
21
"github.com/openshift/odo/pkg/envinfo"
21
- "github.com/openshift/odo/pkg/envinfo/mocks"
22
22
"github.com/openshift/odo/pkg/occlient"
23
23
"github.com/openshift/odo/pkg/testingutil"
24
24
@@ -33,7 +33,7 @@ import (
33
33
. "github.com/openshift/odo/pkg/config"
34
34
)
35
35
36
- func TestGomockGetComponentFrom (t * testing.T ) {
36
+ func TestGetComponentFrom (t * testing.T ) {
37
37
type cmpSetting struct {
38
38
componentName string
39
39
project string
@@ -145,117 +145,6 @@ func TestGomockGetComponentFrom(t *testing.T) {
145
145
}
146
146
}
147
147
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
-
259
148
func TestGetS2IPaths (t * testing.T ) {
260
149
261
150
tests := []struct {
0 commit comments