@@ -290,13 +290,15 @@ func TestDependencyManager_build(t *testing.T) {
290
290
291
291
func TestDependencyManager_addLocalDependency (t * testing.T ) {
292
292
tests := []struct {
293
- name string
294
- dep * helmchart.Dependency
295
- wantErr string
296
- wantFunc func (g * WithT , c * helmchart.Chart )
293
+ name string
294
+ chartName string
295
+ dep * helmchart.Dependency
296
+ wantErr string
297
+ wantFunc func (g * WithT , c * helmchart.Chart )
297
298
}{
298
299
{
299
- name : "local dependency" ,
300
+ name : "local dependency" ,
301
+ chartName : "helmchartwithdeps" ,
300
302
dep : & helmchart.Dependency {
301
303
Name : chartName ,
302
304
Version : chartVersion ,
@@ -307,7 +309,8 @@ func TestDependencyManager_addLocalDependency(t *testing.T) {
307
309
},
308
310
},
309
311
{
310
- name : "version not matching constraint" ,
312
+ name : "version not matching constraint" ,
313
+ chartName : "helmchartwithdeps" ,
311
314
dep : & helmchart.Dependency {
312
315
Name : chartName ,
313
316
Version : "0.2.0" ,
@@ -316,7 +319,8 @@ func TestDependencyManager_addLocalDependency(t *testing.T) {
316
319
wantErr : "can't get a valid version for constraint '0.2.0'" ,
317
320
},
318
321
{
319
- name : "invalid local reference" ,
322
+ name : "invalid local reference" ,
323
+ chartName : "helmchartwithdeps" ,
320
324
dep : & helmchart.Dependency {
321
325
Name : chartName ,
322
326
Version : chartVersion ,
@@ -325,7 +329,8 @@ func TestDependencyManager_addLocalDependency(t *testing.T) {
325
329
wantErr : "no chart found at '/absolutely/invalid'" ,
326
330
},
327
331
{
328
- name : "invalid chart archive" ,
332
+ name : "invalid chart archive" ,
333
+ chartName : "helmchartwithdeps" ,
329
334
dep : & helmchart.Dependency {
330
335
Name : chartName ,
331
336
Version : chartVersion ,
@@ -334,14 +339,35 @@ func TestDependencyManager_addLocalDependency(t *testing.T) {
334
339
wantErr : "failed to load chart from '/empty.tgz'" ,
335
340
},
336
341
{
337
- name : "invalid constraint" ,
342
+ name : "invalid constraint" ,
343
+ chartName : "helmchartwithdeps" ,
338
344
dep : & helmchart.Dependency {
339
345
Name : chartName ,
340
346
Version : "invalid" ,
341
347
Repository : "file://../helmchart" ,
342
348
},
343
349
wantErr : "invalid version/constraint format 'invalid'" ,
344
350
},
351
+ {
352
+ name : "no repository" ,
353
+ chartName : "helmchartwithdepsnorepo" ,
354
+ dep : & helmchart.Dependency {
355
+ Name : chartName ,
356
+ Version : chartVersion ,
357
+ },
358
+ wantFunc : func (g * WithT , c * helmchart.Chart ) {
359
+ g .Expect (c .Dependencies ()).To (HaveLen (1 ))
360
+ },
361
+ },
362
+ {
363
+ name : "no repository invalid reference" ,
364
+ chartName : "helmchartwithdepsnorepo" ,
365
+ dep : & helmchart.Dependency {
366
+ Name : "nonexistingchart" ,
367
+ Version : chartVersion ,
368
+ },
369
+ wantErr : "no chart found at '/helmchartwithdepsnorepo/charts/nonexistingchart'" ,
370
+ },
345
371
}
346
372
for _ , tt := range tests {
347
373
t .Run (tt .name , func (t * testing.T ) {
@@ -353,7 +379,7 @@ func TestDependencyManager_addLocalDependency(t *testing.T) {
353
379
absWorkDir , err := filepath .Abs ("../testdata/charts" )
354
380
g .Expect (err ).ToNot (HaveOccurred ())
355
381
356
- err = dm .addLocalDependency (LocalReference {WorkDir : absWorkDir , Path : "helmchartwithdeps" },
382
+ err = dm .addLocalDependency (LocalReference {WorkDir : absWorkDir , Path : tt . chartName },
357
383
& chartWithLock {Chart : chart }, tt .dep )
358
384
if tt .wantErr != "" {
359
385
g .Expect (err ).To (HaveOccurred ())
@@ -844,6 +870,15 @@ func TestDependencyManager_secureLocalChartPath(t *testing.T) {
844
870
},
845
871
wantErr : "not a local chart reference" ,
846
872
},
873
+ {
874
+ name : "local dependency with empty repository" ,
875
+ dep : & helmchart.Dependency {
876
+ Name : "some-subchart" ,
877
+ },
878
+ baseDir : "/tmp/workdir" ,
879
+ path : "/chart" ,
880
+ want : "/tmp/workdir/chart/charts/some-subchart" ,
881
+ },
847
882
}
848
883
for _ , tt := range tests {
849
884
t .Run (tt .name , func (t * testing.T ) {
0 commit comments