Skip to content

Commit

Permalink
Demonstrate the error that occurs when pushing a commit with a bad date
Browse files Browse the repository at this point in the history
  • Loading branch information
spraints committed Nov 7, 2024
1 parent 20bb13d commit 56ba21e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ go-test-integration:

# Add our compiled `spokes-receive-pack` to the PATH while running tests:
PATH="$(CURDIR)/bin:$(PATH)" \
GIT_CONFIG_SYSTEM="$(CURDIR)/internal/integration/testdata/gitconfig" \
$(GO) test $(TESTINTEGRATIONFLAGS) $(TESTSUITE) 2>&1

@echo "$(M) disabling failpoints ..."
Expand Down
17 changes: 17 additions & 0 deletions internal/integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ committer Spokes Receive Pack <[email protected]> 1234567890 +0000
This commit object intentionally broken
`

var suiteDir string = func() string {
pwd, err := os.Getwd()
if err != nil {
panic(err)
}
return pwd
}()

type SpokesReceivePackTestSuite struct {
suite.Suite
localRepo, remoteRepo string
Expand Down Expand Up @@ -181,6 +189,15 @@ func (suite *SpokesReceivePackTestSuite) TestSpokesReceivePackHiddenRefs() {
"should partially fail")
}

func (suite *SpokesReceivePackTestSuite) TestBadDate() {
cmd := exec.Command("git", "-C", filepath.Join(suiteDir, "testdata/bad-date/sha1.git"),
"push", "--receive-pack=spokes-receive-pack-wrapper", suite.remoteRepo, "main")
out, err := cmd.CombinedOutput()
suite.T().Logf("$ git %s\n%s", strings.Join(cmd.Args, " "), out)
assert.Error(suite.T(), err, "expect an error a repo with a malformed committer line in a commit")
assert.Contains(suite.T(), string(out), " badDate:", "should complain about a bad date")
}

func (suite *SpokesReceivePackTestSuite) TestWithGovernor() {
started := make(chan any)
govSock, msgs, cleanup := startFakeGovernor(suite.T(), started, nil)
Expand Down
4 changes: 4 additions & 0 deletions internal/integration/testdata/gitconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# This file has a subset of options from our prod /etc/gitconfig.

[receive]
fsckObjects = true

0 comments on commit 56ba21e

Please sign in to comment.