Not parallel: the git helpers shell out in the process working directory, so the test switches cwd, which is process-global.
(t *testing.T)
| 28 | // Not parallel: the git helpers shell out in the process working directory, so |
| 29 | // the test switches cwd, which is process-global. |
| 30 | func Test_verifyReleaseRef(t *testing.T) { |
| 31 | repo := newGitRepoWithRemote(t) |
| 32 | |
| 33 | t.Run("passes when HEAD is at remote default tip", func(t *testing.T) { |
| 34 | assert.NoError(t, verifyReleaseRef(repo.ctxAt(t))) |
| 35 | }) |
| 36 | |
| 37 | t.Run("fails on a local-only commit", func(t *testing.T) { |
| 38 | repo.commit(t, "chore: bump local/v0.0.1") |
| 39 | err := verifyReleaseRef(repo.ctxAt(t)) |
| 40 | require.Error(t, err) |
| 41 | assert.Contains(t, err.Error(), "refusing to tag") |
| 42 | }) |
| 43 | |
| 44 | t.Run("passes again once the commit is pushed", func(t *testing.T) { |
| 45 | // Self-contained: put HEAD ahead of the remote, assert it fails, then |
| 46 | // push and assert it recovers — so the fail -> push -> pass sequence is |
| 47 | // exercised even when this subtest is run in isolation. |
| 48 | repo.commit(t, "chore: bump local/v0.0.2") |
| 49 | require.Error(t, verifyReleaseRef(repo.ctxAt(t))) |
| 50 | |
| 51 | repo.run(t, "push", "origin", "HEAD:main") |
| 52 | assert.NoError(t, verifyReleaseRef(repo.ctxAt(t))) |
| 53 | }) |
| 54 | } |
| 55 | |
| 56 | type gitRepo struct { |
| 57 | dir string |
nothing calls this directly
no test coverage detected