(t *testing.T)
| 666 | } |
| 667 | |
| 668 | func TestSubmodule(t *testing.T) { |
| 669 | t.Parallel() |
| 670 | |
| 671 | tmp, err := ioutil.TempDir("", "submodule") |
| 672 | require.NoError(t, err, "creating temporary directory") |
| 673 | |
| 674 | defer func() { |
| 675 | os.RemoveAll(tmp) |
| 676 | }() |
| 677 | |
| 678 | timestamp := time.Unix(1112911993, 0) |
| 679 | |
| 680 | submRepo := testutils.TestRepo{ |
| 681 | Path: filepath.Join(tmp, "subm"), |
| 682 | } |
| 683 | submRepo.Init(t, false) |
| 684 | submRepo.AddFile(t, "submfile1.txt", "Hello, submodule!\n") |
| 685 | submRepo.AddFile(t, "submfile2.txt", "Hello again, submodule!\n") |
| 686 | submRepo.AddFile(t, "submfile3.txt", "Hello again, submodule!\n") |
| 687 | |
| 688 | cmd := submRepo.GitCommand(t, "commit", "-m", "subm initial") |
| 689 | testutils.AddAuthorInfo(cmd, ×tamp) |
| 690 | require.NoError(t, cmd.Run(), "creating subm commit") |
| 691 | |
| 692 | mainRepo := testutils.TestRepo{ |
| 693 | Path: filepath.Join(tmp, "main"), |
| 694 | } |
| 695 | mainRepo.Init(t, false) |
| 696 | |
| 697 | mainRepo.AddFile(t, "mainfile.txt", "Hello, main!\n") |
| 698 | |
| 699 | cmd = mainRepo.GitCommand(t, "commit", "-m", "main initial") |
| 700 | testutils.AddAuthorInfo(cmd, ×tamp) |
| 701 | require.NoError(t, cmd.Run(), "creating main commit") |
| 702 | |
| 703 | // Make subm a submodule of main: |
| 704 | cmd = mainRepo.GitCommand(t, "submodule", "add", submRepo.Path, "sub") |
| 705 | cmd.Dir = mainRepo.Path |
| 706 | require.NoError(t, cmd.Run(), "adding submodule") |
| 707 | |
| 708 | cmd = mainRepo.GitCommand(t, "commit", "-m", "add submodule") |
| 709 | testutils.AddAuthorInfo(cmd, ×tamp) |
| 710 | require.NoError(t, cmd.Run(), "committing submodule to main") |
| 711 | |
| 712 | // Analyze the main repo: |
| 713 | h, err := sizes.ScanRepositoryUsingGraph( |
| 714 | mainRepo.Repository(t), |
| 715 | refGrouper{}, sizes.NameStyleNone, meter.NoProgressMeter, |
| 716 | ) |
| 717 | require.NoError(t, err, "scanning repository") |
| 718 | assert.Equal(t, counts.Count32(2), h.UniqueBlobCount, "unique blob count") |
| 719 | assert.Equal(t, counts.Count32(2), h.MaxExpandedBlobCount, "max expanded blob count") |
| 720 | assert.Equal(t, counts.Count32(1), h.MaxExpandedSubmoduleCount, "max expanded submodule count") |
| 721 | |
| 722 | // Analyze the submodule: |
| 723 | submRepo2 := testutils.TestRepo{ |
| 724 | Path: filepath.Join(mainRepo.Path, "sub"), |
| 725 | } |
nothing calls this directly
no test coverage detected