(c *C)
| 459 | } |
| 460 | |
| 461 | func (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 | |
| 497 | func (s *WorktreeSuite) TestCommitSignBadKey(c *C) { |
| 498 | fs := memfs.New() |
nothing calls this directly
no test coverage detected