@@ -403,4 +403,106 @@ func TestAccGithubRepositoryFile(t *testing.T) {
403403 testCase (t , organization )
404404 })
405405 })
406+
407+ t .Run ("handles files larger than 1MB with raw encoding" , func (t * testing.T ) {
408+ randomID := acctest .RandStringFromCharSet (5 , acctest .CharSetAlphaNum )
409+
410+ initialContent := strings .Repeat ("A" , 1200000 )
411+ updatedContent := strings .Repeat ("B" , 1200000 )
412+
413+ initialConfig := fmt .Sprintf (`
414+ resource "github_repository" "test" {
415+ name = "tf-acc-test-large-file-%s"
416+ auto_init = true
417+ vulnerability_alerts = true
418+ }
419+
420+ resource "github_repository_file" "test" {
421+ repository = github_repository.test.name
422+ branch = "main"
423+ file = "large-file.txt"
424+ content = %q
425+ commit_message = "Add large file (>1MB) to test raw encoding"
426+ commit_author = "Terraform User"
427+ commit_email = "terraform@example.com"
428+ }
429+ ` , randomID , initialContent )
430+
431+ updatedConfig := fmt .Sprintf (`
432+ resource "github_repository" "test" {
433+ name = "tf-acc-test-large-file-%s"
434+ auto_init = true
435+ vulnerability_alerts = true
436+ }
437+
438+ resource "github_repository_file" "test" {
439+ repository = github_repository.test.name
440+ branch = "main"
441+ file = "large-file.txt"
442+ content = %q
443+ commit_message = "Update large file (>1MB) to test raw encoding on read"
444+ commit_author = "Terraform User"
445+ commit_email = "terraform@example.com"
446+ }
447+ ` , randomID , updatedContent )
448+
449+ initialCheck := resource .ComposeTestCheckFunc (
450+ resource .TestCheckResourceAttr (
451+ "github_repository_file.test" , "content" ,
452+ initialContent ,
453+ ),
454+ resource .TestCheckResourceAttrSet (
455+ "github_repository_file.test" , "sha" ,
456+ ),
457+ resource .TestCheckResourceAttrSet (
458+ "github_repository_file.test" , "commit_sha" ,
459+ ),
460+ resource .TestCheckResourceAttr (
461+ "github_repository_file.test" , "file" ,
462+ "large-file.txt" ,
463+ ),
464+ )
465+
466+ updatedCheck := resource .ComposeTestCheckFunc (
467+ resource .TestCheckResourceAttr (
468+ "github_repository_file.test" , "content" ,
469+ updatedContent ,
470+ ),
471+ resource .TestCheckResourceAttrSet (
472+ "github_repository_file.test" , "sha" ,
473+ ),
474+ resource .TestCheckResourceAttrSet (
475+ "github_repository_file.test" , "commit_sha" ,
476+ ),
477+ )
478+
479+ testCase := func (t * testing.T , mode string ) {
480+ resource .Test (t , resource.TestCase {
481+ PreCheck : func () { skipUnlessMode (t , mode ) },
482+ Providers : testAccProviders ,
483+ Steps : []resource.TestStep {
484+ {
485+ Config : initialConfig ,
486+ Check : initialCheck ,
487+ },
488+ {
489+ Config : updatedConfig ,
490+ Check : updatedCheck ,
491+ },
492+ },
493+ })
494+ }
495+
496+ t .Run ("with an anonymous account" , func (t * testing.T ) {
497+ t .Skip ("anonymous account not supported for this operation" )
498+ })
499+
500+ t .Run ("with an individual account" , func (t * testing.T ) {
501+ testCase (t , individual )
502+ })
503+
504+ t .Run ("with an organization account" , func (t * testing.T ) {
505+ testCase (t , organization )
506+ })
507+ })
406508}
0 commit comments