@@ -750,63 +750,63 @@ func TestProcessStackFile_NoGhostEntry_FilterByStack(t *testing.T) {
750750
751751// TestSetStackDescription covers all branches of the setStackDescription helper.
752752func TestSetStackDescription (t * testing.T ) {
753- t .Run ("sections filter excludes description – no-op" , func (t * testing.T ) {
754- finalMap := map [string ]any {
755- "my-stack" : map [string ]any {},
756- }
757- // sections is non-empty but does not include "description", so the early return should fire.
758- setStackDescription (finalMap , "my-stack" , "some description" , []string {"vars" })
759- stackEntry := finalMap ["my-stack" ].(map [string ]any )
760- _ , exists := stackEntry [cfg .DescriptionSectionName ]
761- assert .False (t , exists , "description should not be set when it is absent from the sections filter" )
762- })
763-
764- t .Run ("empty description – no-op" , func (t * testing.T ) {
765- finalMap := map [string ]any {
766- "my-stack" : map [string ]any {},
767- }
768- setStackDescription (finalMap , "my-stack" , "" , nil )
769- stackEntry := finalMap ["my-stack" ].(map [string ]any )
770- _ , exists := stackEntry [cfg .DescriptionSectionName ]
771- assert .False (t , exists , "description should not be set when value is empty string" )
772- })
773-
774- t .Run ("finalStacksMap entry not a map – no-op" , func (t * testing.T ) {
775- finalMap := map [string ]any {
776- "my-stack" : "not-a-map" ,
777- }
778- // Should not panic; the non-map stack entry triggers the guard and returns.
779- setStackDescription (finalMap , "my-stack" , "some description" , nil )
780- // Entry remains unchanged.
781- assert .Equal (t , "not-a-map" , finalMap ["my-stack" ])
782- })
783-
784- t .Run ("description set on first call" , func (t * testing.T ) {
785- finalMap := map [string ]any {
786- "my-stack" : map [string ]any {},
787- }
788- setStackDescription (finalMap , "my-stack" , "hello world" , nil )
789- stackEntry := finalMap ["my-stack" ].(map [string ]any )
790- assert .Equal (t , "hello world" , stackEntry [cfg .DescriptionSectionName ])
791- })
792-
793- t .Run ("idempotent – second call does not overwrite" , func (t * testing.T ) {
794- finalMap := map [string ]any {
795- "my-stack" : map [string ]any {
796- cfg .DescriptionSectionName : "original" ,
797- },
798- }
799- setStackDescription (finalMap , "my-stack" , "overwrite-attempt" , nil )
800- stackEntry := finalMap ["my-stack" ].(map [string ]any )
801- assert .Equal (t , "original" , stackEntry [cfg .DescriptionSectionName ], "existing description should not be overwritten" )
802- })
803-
804- t .Run ("sections filter includes description – description is set" , func (t * testing.T ) {
805- finalMap := map [string ]any {
806- "my-stack" : map [string ]any {},
807- }
808- setStackDescription (finalMap , "my-stack" , "filtered in" , []string {cfg .DescriptionSectionName })
809- stackEntry := finalMap ["my-stack" ].(map [string ]any )
810- assert .Equal (t , "filtered in" , stackEntry [cfg .DescriptionSectionName ])
811- })
753+ t .Run ("sections filter excludes description – no-op" , func (t * testing.T ) {
754+ finalMap := map [string ]any {
755+ "my-stack" : map [string ]any {},
756+ }
757+ // sections is non-empty but does not include "description", so the early return should fire.
758+ setStackDescription (finalMap , "my-stack" , "some description" , []string {"vars" })
759+ stackEntry := finalMap ["my-stack" ].(map [string ]any )
760+ _ , exists := stackEntry [cfg .DescriptionSectionName ]
761+ assert .False (t , exists , "description should not be set when it is absent from the sections filter" )
762+ })
763+
764+ t .Run ("empty description – no-op" , func (t * testing.T ) {
765+ finalMap := map [string ]any {
766+ "my-stack" : map [string ]any {},
767+ }
768+ setStackDescription (finalMap , "my-stack" , "" , nil )
769+ stackEntry := finalMap ["my-stack" ].(map [string ]any )
770+ _ , exists := stackEntry [cfg .DescriptionSectionName ]
771+ assert .False (t , exists , "description should not be set when value is empty string" )
772+ })
773+
774+ t .Run ("finalStacksMap entry not a map – no-op" , func (t * testing.T ) {
775+ finalMap := map [string ]any {
776+ "my-stack" : "not-a-map" ,
777+ }
778+ // Should not panic; the non-map stack entry triggers the guard and returns.
779+ setStackDescription (finalMap , "my-stack" , "some description" , nil )
780+ // Entry remains unchanged.
781+ assert .Equal (t , "not-a-map" , finalMap ["my-stack" ])
782+ })
783+
784+ t .Run ("description set on first call" , func (t * testing.T ) {
785+ finalMap := map [string ]any {
786+ "my-stack" : map [string ]any {},
787+ }
788+ setStackDescription (finalMap , "my-stack" , "hello world" , nil )
789+ stackEntry := finalMap ["my-stack" ].(map [string ]any )
790+ assert .Equal (t , "hello world" , stackEntry [cfg .DescriptionSectionName ])
791+ })
792+
793+ t .Run ("idempotent – second call does not overwrite" , func (t * testing.T ) {
794+ finalMap := map [string ]any {
795+ "my-stack" : map [string ]any {
796+ cfg .DescriptionSectionName : "original" ,
797+ },
798+ }
799+ setStackDescription (finalMap , "my-stack" , "overwrite-attempt" , nil )
800+ stackEntry := finalMap ["my-stack" ].(map [string ]any )
801+ assert .Equal (t , "original" , stackEntry [cfg .DescriptionSectionName ], "existing description should not be overwritten" )
802+ })
803+
804+ t .Run ("sections filter includes description – description is set" , func (t * testing.T ) {
805+ finalMap := map [string ]any {
806+ "my-stack" : map [string ]any {},
807+ }
808+ setStackDescription (finalMap , "my-stack" , "filtered in" , []string {cfg .DescriptionSectionName })
809+ stackEntry := finalMap ["my-stack" ].(map [string ]any )
810+ assert .Equal (t , "filtered in" , stackEntry [cfg .DescriptionSectionName ])
811+ })
812812}
0 commit comments