@@ -77,11 +77,11 @@ func createMockCatalogService(t *testing.T, opts *options.TerragruntOptions) cat
7777 repoURL := repoOpts .CloneURL
7878 dummyRepoDir := filepath .Join (helpers .TmpDirWOSymlinks (t ), strings .ReplaceAll (repoURL , "github.com/gruntwork-io/" , "" ))
7979
80- os .MkdirAll (dummyRepoDir , 0755 )
80+ require . NoError ( t , os .MkdirAll (dummyRepoDir , 0755 ), "MkdirAll %s" , dummyRepoDir )
8181
8282 gitDir := filepath .Join (dummyRepoDir , ".git" )
83- os .MkdirAll (gitDir , 0755 )
84- os .WriteFile (filepath .Join (gitDir , "config" ), fmt .Appendf (nil , `[core]
83+ require . NoError ( t , os .MkdirAll (gitDir , 0755 ), "MkdirAll %s" , gitDir )
84+ require . NoError ( t , os .WriteFile (filepath .Join (gitDir , "config" ), fmt .Appendf (nil , `[core]
8585 repositoryformatversion = 0
8686 filemode = true
8787 bare = false
@@ -92,29 +92,33 @@ func createMockCatalogService(t *testing.T, opts *options.TerragruntOptions) cat
9292[branch "main"]
9393 remote = origin
9494 merge = refs/heads/main
95- ` , repoURL ), 0644 )
96- os .WriteFile (filepath .Join (gitDir , "HEAD" ), []byte ("ref: refs/heads/main\n " ), 0644 )
95+ ` , repoURL ), 0644 ), "WriteFile %s/config" , gitDir )
96+ require . NoError ( t , os .WriteFile (filepath .Join (gitDir , "HEAD" ), []byte ("ref: refs/heads/main\n " ), 0644 ), "WriteFile %s/HEAD" , gitDir )
9797
9898 refsDir := filepath .Join (gitDir , "refs" )
9999 headsDir := filepath .Join (refsDir , "heads" )
100100 remotesDir := filepath .Join (refsDir , "remotes" , "origin" )
101101
102- os .MkdirAll (headsDir , 0755 )
103- os .MkdirAll (remotesDir , 0755 )
102+ require . NoError ( t , os .MkdirAll (headsDir , 0755 ), "MkdirAll %s" , headsDir )
103+ require . NoError ( t , os .MkdirAll (remotesDir , 0755 ), "MkdirAll %s" , remotesDir )
104104
105105 fakeCommitHash := "1234567890abcdef1234567890abcdef12345678"
106- os .WriteFile (filepath .Join (headsDir , "main" ), []byte (fakeCommitHash + "\n " ), 0644 )
107- os .WriteFile (filepath .Join (remotesDir , "main" ), []byte (fakeCommitHash + "\n " ), 0644 )
106+ require . NoError ( t , os .WriteFile (filepath .Join (headsDir , "main" ), []byte (fakeCommitHash + "\n " ), 0644 ), "WriteFile %s/main" , headsDir )
107+ require . NoError ( t , os .WriteFile (filepath .Join (remotesDir , "main" ), []byte (fakeCommitHash + "\n " ), 0644 ), "WriteFile %s/main" , remotesDir )
108108
109109 switch repoURL {
110110 case "github.com/gruntwork-io/test-repo-1" :
111111 readme1Path := filepath .Join (dummyRepoDir , "README.md" )
112- os .WriteFile (readme1Path , []byte ("# AWS VPC Module\n This module creates a VPC in AWS with all the necessary components." ), 0644 )
113- os .WriteFile (filepath .Join (dummyRepoDir , "main.tf" ), []byte ("# VPC terraform configuration" ), 0644 )
112+ require .NoError (t , os .WriteFile (readme1Path , []byte ("# AWS VPC Module\n This module creates a VPC in AWS with all the necessary components." ), 0644 ), "WriteFile %s" , readme1Path )
113+
114+ mainTF1 := filepath .Join (dummyRepoDir , "main.tf" )
115+ require .NoError (t , os .WriteFile (mainTF1 , []byte ("# VPC terraform configuration" ), 0644 ), "WriteFile %s" , mainTF1 )
114116 case "github.com/gruntwork-io/test-repo-2" :
115117 readme2Path := filepath .Join (dummyRepoDir , "README.md" )
116- os .WriteFile (readme2Path , []byte ("# AWS EKS Module\n This module creates an EKS cluster in AWS." ), 0644 )
117- os .WriteFile (filepath .Join (dummyRepoDir , "main.tf" ), []byte ("# EKS terraform configuration" ), 0644 )
118+ require .NoError (t , os .WriteFile (readme2Path , []byte ("# AWS EKS Module\n This module creates an EKS cluster in AWS." ), 0644 ), "WriteFile %s" , readme2Path )
119+
120+ mainTF2 := filepath .Join (dummyRepoDir , "main.tf" )
121+ require .NoError (t , os .WriteFile (mainTF2 , []byte ("# EKS terraform configuration" ), 0644 ), "WriteFile %s" , mainTF2 )
118122 default :
119123 return nil , fmt .Errorf ("unexpected repoURL in mock: %s" , repoURL )
120124 }
@@ -135,7 +139,7 @@ func createMockCatalogService(t *testing.T, opts *options.TerragruntOptions) cat
135139 require .NoError (t , err )
136140
137141 unitDir := filepath .Join (tmpDir , "unit" )
138- os .MkdirAll (unitDir , 0755 )
142+ require . NoError ( t , os .MkdirAll (unitDir , 0755 ), "MkdirAll %s" , unitDir )
139143 opts .TerragruntConfigPath = filepath .Join (unitDir , "terragrunt.hcl" )
140144 opts .ScaffoldRootFileName = config .RecommendedParentConfigName
141145
@@ -182,10 +186,10 @@ func TestModelStreamingInsertsSorted(t *testing.T) {
182186 items := finalModel .List .Items ()
183187 assert .Len (t , items , len (modules ), "all modules should be in the list" )
184188
185- // Verify sorted order
189+ // Verify sorted order (case-insensitive, matching the sort in model.go)
186190 for i := 1 ; i < len (items ); i ++ {
187- prev := items [i - 1 ].(* module.Module ).Title ()
188- curr := items [i ].(* module.Module ).Title ()
191+ prev := strings . ToLower ( items [i - 1 ].(* module.Module ).Title () )
192+ curr := strings . ToLower ( items [i ].(* module.Module ).Title () )
189193 assert .LessOrEqual (t , prev , curr , "modules should be in alphabetical order: %q should come before %q" , prev , curr )
190194 }
191195}
0 commit comments