(c *C)
| 339 | } |
| 340 | |
| 341 | func (s *WorktreeSuite) TestCommitSign(c *C) { |
| 342 | fs := memfs.New() |
| 343 | storage := memory.NewStorage() |
| 344 | |
| 345 | r, err := Init(storage, fs) |
| 346 | c.Assert(err, IsNil) |
| 347 | |
| 348 | w, err := r.Worktree() |
| 349 | c.Assert(err, IsNil) |
| 350 | |
| 351 | util.WriteFile(fs, "foo", []byte("foo"), 0644) |
| 352 | |
| 353 | _, err = w.Add("foo") |
| 354 | c.Assert(err, IsNil) |
| 355 | |
| 356 | key := commitSignKey(c, true) |
| 357 | hash, err := w.Commit("foo\n", &CommitOptions{Author: defaultSignature(), SignKey: key}) |
| 358 | c.Assert(err, IsNil) |
| 359 | |
| 360 | // Verify the commit. |
| 361 | pks := new(bytes.Buffer) |
| 362 | pkw, err := armor.Encode(pks, openpgp.PublicKeyType, nil) |
| 363 | c.Assert(err, IsNil) |
| 364 | |
| 365 | err = key.Serialize(pkw) |
| 366 | c.Assert(err, IsNil) |
| 367 | err = pkw.Close() |
| 368 | c.Assert(err, IsNil) |
| 369 | |
| 370 | expectedCommit, err := r.CommitObject(hash) |
| 371 | c.Assert(err, IsNil) |
| 372 | actual, err := expectedCommit.Verify(pks.String()) |
| 373 | c.Assert(err, IsNil) |
| 374 | c.Assert(actual.PrimaryKey, DeepEquals, key.PrimaryKey) |
| 375 | } |
| 376 | |
| 377 | func (s *WorktreeSuite) TestCommitSignBadKey(c *C) { |
| 378 | fs := memfs.New() |
nothing calls this directly
no test coverage detected