MCPcopy Create free account
hub / github.com/docker/secrets-engine / Test_verifyReleaseRef

Function Test_verifyReleaseRef

x/release/command_test.go:30–54  ·  view source on GitHub ↗

Not parallel: the git helpers shell out in the process working directory, so the test switches cwd, which is process-global.

(t *testing.T)

Source from the content-addressed store, hash-verified

28// Not parallel: the git helpers shell out in the process working directory, so
29// the test switches cwd, which is process-global.
30func 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
56type gitRepo struct {
57 dir string

Callers

nothing calls this directly

Calls 7

newGitRepoWithRemoteFunction · 0.85
verifyReleaseRefFunction · 0.85
ctxAtMethod · 0.80
commitMethod · 0.80
runMethod · 0.80
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected