Skip to content

Commit

Permalink
Use a file for the empty pack
Browse files Browse the repository at this point in the history
The empty pack is the same for all of these tests, so we can generate it
once, store it in the repo, and avoid the complexity of shelling out to
git during the tests.

Here's how I generated the file:

  $ git pack-objects --revs --stdout > internal/integration/testdata/empty.pack </dev/null
  Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
  • Loading branch information
spraints committed Apr 6, 2023
1 parent 1488c82 commit 2e77fa7
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 12 deletions.
5 changes: 1 addition & 4 deletions internal/integration/hiderefs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,8 @@ func TestHiderefsConfig(t *testing.T) {

// Send an empty pack, since we're using commits that are already in
// the repo.
packObjects := exec.CommandContext(ctx, "git", "-C", testRepo, "pack-objects", "--all-progress-implied", "--revs", "--stdout", "--thin", "--delta-base-offset", "--progress")
packObjects.Stderr = os.Stderr
pack, err := packObjects.StdoutPipe()
pack, err := os.Open("testdata/empty.pack")
require.NoError(t, err)
go packObjects.Run()
if _, err := io.Copy(srpIn, pack); err != nil {
t.Logf("error writing pack to spokes-receive-pack input: %v", err)
}
Expand Down
5 changes: 1 addition & 4 deletions internal/integration/nosideband_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,8 @@ func TestNoSideBand(t *testing.T) {

// Send an empty pack, since we're using commits that are already in
// the repo.
packObjects := exec.CommandContext(ctx, "git", "-C", testRepo, "pack-objects", "--all-progress-implied", "--revs", "--stdout", "--thin", "--delta-base-offset", "--progress")
packObjects.Stderr = os.Stderr
pack, err := packObjects.StdoutPipe()
pack, err := os.Open("testdata/empty.pack")
require.NoError(t, err)
go packObjects.Run()
if _, err := io.Copy(srpIn, pack); err != nil {
t.Logf("error writing pack to spokes-receive-pack input: %v", err)
}
Expand Down
5 changes: 1 addition & 4 deletions internal/integration/pushoptions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,8 @@ func TestPushOptions(t *testing.T) {

// Send an empty pack, since we're using commits that are already in
// the repo.
packObjects := exec.CommandContext(ctx, "git", "-C", testRepo, "pack-objects", "--all-progress-implied", "--revs", "--stdout", "--thin", "--delta-base-offset", "--progress")
packObjects.Stderr = os.Stderr
pack, err := packObjects.StdoutPipe()
pack, err := os.Open("testdata/empty.pack")
require.NoError(t, err)
go packObjects.Run()
if _, err := io.Copy(srpIn, pack); err != nil {
t.Logf("error writing pack to spokes-receive-pack input: %v", err)
}
Expand Down
Binary file added internal/integration/testdata/empty.pack
Binary file not shown.

0 comments on commit 2e77fa7

Please sign in to comment.