@@ -612,7 +612,7 @@ func TestProcessHelmComponentsIndexed_FolderChanged(t *testing.T) {
612612 assert .Contains (t , affected [0 ].AffectedAll , affectedReasonComponent )
613613}
614614
615- func TestProcessHelmComponentsIndexed_ValuesFileChangedOutsideComponentBasePath (t * testing.T ) {
615+ func TestProcessHelmComponentsIndexed_ValuesFilesChanged (t * testing.T ) {
616616 tempDir := t .TempDir ()
617617 atmosConfig := helmAtmosConfig ()
618618 atmosConfig .BasePath = tempDir
@@ -623,109 +623,45 @@ func TestProcessHelmComponentsIndexed_ValuesFileChangedOutsideComponentBasePath(
623623 valuesRef , err := filepath .Rel (componentPath , valuesFile )
624624 require .NoError (t , err )
625625
626- identical := map [string ]any {
627- cfg .ComponentSectionName : componentFolder ,
628- sectionNameChart : "." ,
629- sectionNameValuesF : []any {valuesRef },
630- }
631- helmSection := map [string ]any {helmTestComponent : identical }
632- remoteStacks := helmRemoteStacksWith (identical )
633- filesIndex := newChangedFilesIndex (atmosConfig , []string {valuesFile }, tempDir )
634-
635- affected , err := processHelmComponentsIndexed (
636- helmTestStack , helmSection , & remoteStacks , & remoteStacks ,
637- atmosConfig , filesIndex , newComponentPathPatternCache (),
638- false , false , false ,
639- )
640- require .NoError (t , err )
641-
642- require .Len (t , affected , 1 )
643- assert .Equal (t , helmTestComponent , affected [0 ].Component )
644- assert .Equal (t , cfg .HelmComponentType , affected [0 ].ComponentType )
645- assert .Contains (t , affected [0 ].AffectedAll , affectedReasonStackValuesFile )
646- }
647-
648- func TestProcessHelmComponentsIndexed_ScalarValuesFileChanged (t * testing.T ) {
649- tempDir := t .TempDir ()
650- atmosConfig := helmAtmosConfig ()
651- atmosConfig .BasePath = tempDir
652-
653- componentFolder := "shared-chart"
654- componentPath := filepath .Join (tempDir , "components" , "helm" , componentFolder )
655- valuesFile := filepath .Join (tempDir , "config" , "helm" , "app-values.yaml" )
656- valuesRef , err := filepath .Rel (componentPath , valuesFile )
657- require .NoError (t , err )
658-
659- identical := map [string ]any {
660- cfg .ComponentSectionName : componentFolder ,
661- sectionNameChart : "." ,
662- sectionNameValuesF : valuesRef ,
663- }
664- helmSection := map [string ]any {helmTestComponent : identical }
665- remoteStacks := helmRemoteStacksWith (identical )
666- filesIndex := newChangedFilesIndex (atmosConfig , []string {valuesFile }, tempDir )
667-
668- affected , err := processHelmComponentsIndexed (
669- helmTestStack , helmSection , & remoteStacks , & remoteStacks ,
670- atmosConfig , filesIndex , newComponentPathPatternCache (),
671- false , false , false ,
672- )
673- require .NoError (t , err )
674-
675- require .Len (t , affected , 1 )
676- assert .Equal (t , helmTestComponent , affected [0 ].Component )
677- assert .Equal (t , cfg .HelmComponentType , affected [0 ].ComponentType )
678- assert .Contains (t , affected [0 ].AffectedAll , affectedReasonStackValuesFile )
679- }
680-
681- func TestProcessHelmComponentsIndexed_AbsoluteValuesFileChanged (t * testing.T ) {
682- tempDir := t .TempDir ()
683- atmosConfig := helmAtmosConfig ()
684- atmosConfig .BasePath = tempDir
685-
686- valuesFile := filepath .Join (tempDir , "config" , "helm" , "app-values.yaml" )
687- identical := map [string ]any {
688- cfg .ComponentSectionName : "shared-chart" ,
689- sectionNameChart : "." ,
690- sectionNameValuesF : []any {valuesFile },
691- }
692- helmSection := map [string ]any {helmTestComponent : identical }
693- remoteStacks := helmRemoteStacksWith (identical )
694- filesIndex := newChangedFilesIndex (atmosConfig , []string {valuesFile }, tempDir )
695-
696- affected , err := processHelmComponentsIndexed (
697- helmTestStack , helmSection , & remoteStacks , & remoteStacks ,
698- atmosConfig , filesIndex , newComponentPathPatternCache (),
699- false , false , false ,
700- )
701- require .NoError (t , err )
702-
703- require .Len (t , affected , 1 )
704- assert .Equal (t , helmTestComponent , affected [0 ].Component )
705- assert .Equal (t , cfg .HelmComponentType , affected [0 ].ComponentType )
706- assert .Contains (t , affected [0 ].AffectedAll , affectedReasonStackValuesFile )
707- }
626+ for _ , tt := range []struct {
627+ name string
628+ valuesFiles any
629+ changedFile string
630+ wantAffected bool
631+ }{
632+ {name : "relative list" , valuesFiles : []any {valuesRef }, changedFile : valuesFile , wantAffected : true },
633+ {name : "scalar" , valuesFiles : valuesRef , changedFile : valuesFile , wantAffected : true },
634+ {name : "absolute" , valuesFiles : []any {valuesFile }, changedFile : valuesFile , wantAffected : true },
635+ {name : "unrelated" , valuesFiles : []string {valuesRef }, changedFile : filepath .Join (tempDir , "config" , "helm" , "other-values.yaml" )},
636+ } {
637+ t .Run (tt .name , func (t * testing.T ) {
638+ identical := map [string ]any {
639+ cfg .ComponentSectionName : componentFolder ,
640+ sectionNameChart : "." ,
641+ sectionNameValuesF : tt .valuesFiles ,
642+ }
643+ helmSection := map [string ]any {helmTestComponent : identical }
644+ remoteStacks := helmRemoteStacksWith (identical )
645+ filesIndex := newChangedFilesIndex (atmosConfig , []string {tt .changedFile }, tempDir )
646+
647+ affected , err := processHelmComponentsIndexed (
648+ helmTestStack , helmSection , & remoteStacks , & remoteStacks ,
649+ atmosConfig , filesIndex , newComponentPathPatternCache (),
650+ false , false , false ,
651+ )
652+ require .NoError (t , err )
708653
709- func TestProcessHelmComponentsIndexed_UnrelatedFileDoesNotAffectValuesFile ( t * testing. T ) {
710- tempDir := t . TempDir ( )
711- atmosConfig := helmAtmosConfig ()
712- atmosConfig . BasePath = tempDir
654+ if ! tt . wantAffected {
655+ assert . Empty ( t , affected )
656+ return
657+ }
713658
714- identical := map [string ]any {
715- sectionNameChart : "." ,
716- sectionNameValuesF : []string {"../../../config/helm/app-values.yaml" },
659+ require .Len (t , affected , 1 )
660+ assert .Equal (t , helmTestComponent , affected [0 ].Component )
661+ assert .Equal (t , cfg .HelmComponentType , affected [0 ].ComponentType )
662+ assert .Contains (t , affected [0 ].AffectedAll , affectedReasonStackValuesFile )
663+ })
717664 }
718- helmSection := map [string ]any {helmTestComponent : identical }
719- remoteStacks := helmRemoteStacksWith (identical )
720- filesIndex := newChangedFilesIndex (atmosConfig , []string {filepath .Join (tempDir , "config" , "helm" , "other-values.yaml" )}, tempDir )
721-
722- affected , err := processHelmComponentsIndexed (
723- helmTestStack , helmSection , & remoteStacks , & remoteStacks ,
724- atmosConfig , filesIndex , newComponentPathPatternCache (),
725- false , false , false ,
726- )
727- require .NoError (t , err )
728- assert .Empty (t , affected )
729665}
730666
731667func TestProcessHelmComponentsIndexed_SkipsAbstractLockedAndInvalidSections (t * testing.T ) {
0 commit comments