Skip to content

Commit 8945f02

Browse files
committed
Fix tests
Signed-off-by: Mmadu Manasseh <manasseh.mmadu@zapier.com>
1 parent 2df71d3 commit 8945f02

File tree

2 files changed

+60
-3
lines changed

2 files changed

+60
-3
lines changed

pkg/argo_client/manifests.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,12 +458,11 @@ func packageApp(
458458
// Handle local helm dependencies from Chart.yaml
459459
chartPath := filepath.Join(srcAppPath, "Chart.yaml")
460460
if _, err := os.Stat(chartPath); err == nil {
461-
log.Info().Msg("processing helm dependencies")
461+
log.Debug().Msg("processing helm dependencies")
462462
deps, err := parseChartYAML(chartPath)
463463
if err != nil {
464464
return "", errors.Wrap(err, "failed to parse Chart.yaml")
465465
}
466-
log.Info().Msgf("helm dependencies: %+v", deps)
467466

468467
for _, dep := range deps {
469468
if strings.HasPrefix(dep.Repository, "file://") {

pkg/argo_client/manifests_test.go

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,59 @@ resources:
375375
"component1/resource3.yaml": {"git@github.com:testuser/testrepo.git", "main", "component1/resource3.yaml"},
376376
},
377377
},
378+
379+
"helm-dependencies-are-copied": {
380+
pullRequest: vcs.PullRequest{
381+
CloneURL: "git@github.com:testuser/testrepo.git",
382+
BaseRef: "main",
383+
HeadRef: "update-code",
384+
},
385+
app: v1alpha1.Application{
386+
Spec: v1alpha1.ApplicationSpec{
387+
Sources: []v1alpha1.ApplicationSource{
388+
{
389+
RepoURL: "git@github.com:testuser/testrepo.git",
390+
Path: "app1/",
391+
TargetRevision: "main",
392+
Helm: &v1alpha1.ApplicationSourceHelm{
393+
ValueFiles: []string{
394+
"values.yaml",
395+
},
396+
},
397+
},
398+
},
399+
},
400+
},
401+
filesByRepo: map[repoTarget]set[string]{
402+
repoTarget{"git@github.com:testuser/testrepo.git", "main"}: newSet[string](
403+
"app1/values.yaml",
404+
"app1/templates/deployment.yaml",
405+
"charts/dependency/Chart.yaml",
406+
"charts/dependency/values.yaml",
407+
"charts/dependency/templates/deployment.yaml",
408+
),
409+
},
410+
filesByRepoWithContent: map[repoTarget]map[string]string{
411+
repoTarget{"git@github.com:testuser/testrepo.git", "main"}: {
412+
"app1/Chart.yaml": `---
413+
apiVersion: v2
414+
name: test-chart
415+
version: 1.0.0
416+
dependencies:
417+
- name: dependency
418+
version: 1.0.0
419+
repository: file://../charts/dependency`,
420+
},
421+
},
422+
expectedFiles: map[string]repoTargetPath{
423+
"app1/Chart.yaml": {"git@github.com:testuser/testrepo.git", "main", "app1/Chart.yaml"},
424+
"app1/values.yaml": {"git@github.com:testuser/testrepo.git", "main", "app1/values.yaml"},
425+
"app1/templates/deployment.yaml": {"git@github.com:testuser/testrepo.git", "main", "app1/templates/deployment.yaml"},
426+
"charts/dependency/Chart.yaml": {"git@github.com:testuser/testrepo.git", "main", "charts/dependency/Chart.yaml"},
427+
"charts/dependency/values.yaml": {"git@github.com:testuser/testrepo.git", "main", "charts/dependency/values.yaml"},
428+
"charts/dependency/templates/deployment.yaml": {"git@github.com:testuser/testrepo.git", "main", "charts/dependency/templates/deployment.yaml"},
429+
},
430+
},
378431
}
379432

380433
for name, tc := range testCases {
@@ -466,11 +519,16 @@ func createTestRepos(
466519

467520
// ensure the directories exist
468521
filedir := filepath.Dir(fullfilepath)
469-
err = os.MkdirAll(filedir, 0o755)
522+
err = os.MkdirAll(filedir, os.ModePerm)
470523
require.NoError(t, err)
471524

472525
// generate and store content
473526
fileContent := uuid.NewString()
527+
if filepath.Base(file) == "Chart.yaml" {
528+
fileContent = `apiVersion: v2
529+
name: test-chart
530+
version: 1.0.0`
531+
}
474532
fileContents[repoTargetPath{cloneURL.repo, cloneURL.target, file}] = fileContent
475533

476534
// write the file to disk

0 commit comments

Comments
 (0)