MCPcopy
hub / github.com/go-git/go-git / TestCommitSign

Method TestCommitSign

worktree_commit_test.go:461–495  ·  view source on GitHub ↗
(c *C)

Source from the content-addressed store, hash-verified

459}
460
461func (s *WorktreeSuite) TestCommitSign(c *C) {
462 fs := memfs.New()
463 storage := memory.NewStorage()
464
465 r, err := Init(storage, fs)
466 c.Assert(err, IsNil)
467
468 w, err := r.Worktree()
469 c.Assert(err, IsNil)
470
471 util.WriteFile(fs, "foo", []byte("foo"), 0644)
472
473 _, err = w.Add("foo")
474 c.Assert(err, IsNil)
475
476 key := commitSignKey(c, true)
477 hash, err := w.Commit("foo\n", &CommitOptions{Author: defaultSignature(), SignKey: key})
478 c.Assert(err, IsNil)
479
480 // Verify the commit.
481 pks := new(bytes.Buffer)
482 pkw, err := armor.Encode(pks, openpgp.PublicKeyType, nil)
483 c.Assert(err, IsNil)
484
485 err = key.Serialize(pkw)
486 c.Assert(err, IsNil)
487 err = pkw.Close()
488 c.Assert(err, IsNil)
489
490 expectedCommit, err := r.CommitObject(hash)
491 c.Assert(err, IsNil)
492 actual, err := expectedCommit.Verify(pks.String())
493 c.Assert(err, IsNil)
494 c.Assert(actual.PrimaryKey, DeepEquals, key.PrimaryKey)
495}
496
497func (s *WorktreeSuite) TestCommitSignBadKey(c *C) {
498 fs := memfs.New()

Callers

nothing calls this directly

Calls 12

NewStorageFunction · 0.92
InitFunction · 0.85
commitSignKeyFunction · 0.85
defaultSignatureFunction · 0.85
WorktreeMethod · 0.80
CommitObjectMethod · 0.80
CommitMethod · 0.65
EncodeMethod · 0.65
CloseMethod · 0.65
StringMethod · 0.65
AddMethod · 0.45
VerifyMethod · 0.45

Tested by

no test coverage detected