identity: all tests green o/

Michael MurΓ© created

Change summary

cache/bug_cache.go             | 12 ++++++------
cache/repo_cache.go            |  2 +-
commands/select/select_test.go | 14 ++++++++++----
commands/show.go               |  2 +-
doc/man/git-bug-id.1           |  2 +-
5 files changed, 19 insertions(+), 13 deletions(-)

Detailed changes

cache/bug_cache.go πŸ”—

@@ -101,7 +101,7 @@ func (c *BugCache) AddCommentWithFiles(message string, files []git.Hash) error {
 	return c.AddCommentRaw(author, time.Now().Unix(), message, files, nil)
 }
 
-func (c *BugCache) AddCommentRaw(author *identity.Identity, unixTime int64, message string, files []git.Hash, metadata map[string]string) error {
+func (c *BugCache) AddCommentRaw(author identity.Interface, unixTime int64, message string, files []git.Hash, metadata map[string]string) error {
 	op, err := bug.AddCommentWithFiles(c.bug, author, unixTime, message, files)
 	if err != nil {
 		return err
@@ -123,7 +123,7 @@ func (c *BugCache) ChangeLabels(added []string, removed []string) ([]bug.LabelCh
 	return c.ChangeLabelsRaw(author, time.Now().Unix(), added, removed, nil)
 }
 
-func (c *BugCache) ChangeLabelsRaw(author *identity.Identity, unixTime int64, added []string, removed []string, metadata map[string]string) ([]bug.LabelChangeResult, error) {
+func (c *BugCache) ChangeLabelsRaw(author identity.Interface, unixTime int64, added []string, removed []string, metadata map[string]string) ([]bug.LabelChangeResult, error) {
 	changes, op, err := bug.ChangeLabels(c.bug, author, unixTime, added, removed)
 	if err != nil {
 		return changes, err
@@ -150,7 +150,7 @@ func (c *BugCache) Open() error {
 	return c.OpenRaw(author, time.Now().Unix(), nil)
 }
 
-func (c *BugCache) OpenRaw(author *identity.Identity, unixTime int64, metadata map[string]string) error {
+func (c *BugCache) OpenRaw(author identity.Interface, unixTime int64, metadata map[string]string) error {
 	op, err := bug.Open(c.bug, author, unixTime)
 	if err != nil {
 		return err
@@ -172,7 +172,7 @@ func (c *BugCache) Close() error {
 	return c.CloseRaw(author, time.Now().Unix(), nil)
 }
 
-func (c *BugCache) CloseRaw(author *identity.Identity, unixTime int64, metadata map[string]string) error {
+func (c *BugCache) CloseRaw(author identity.Interface, unixTime int64, metadata map[string]string) error {
 	op, err := bug.Close(c.bug, author, unixTime)
 	if err != nil {
 		return err
@@ -194,7 +194,7 @@ func (c *BugCache) SetTitle(title string) error {
 	return c.SetTitleRaw(author, time.Now().Unix(), title, nil)
 }
 
-func (c *BugCache) SetTitleRaw(author *identity.Identity, unixTime int64, title string, metadata map[string]string) error {
+func (c *BugCache) SetTitleRaw(author identity.Interface, unixTime int64, title string, metadata map[string]string) error {
 	op, err := bug.SetTitle(c.bug, author, unixTime, title)
 	if err != nil {
 		return err
@@ -216,7 +216,7 @@ func (c *BugCache) EditComment(target git.Hash, message string) error {
 	return c.EditCommentRaw(author, time.Now().Unix(), target, message, nil)
 }
 
-func (c *BugCache) EditCommentRaw(author *identity.Identity, unixTime int64, target git.Hash, message string, metadata map[string]string) error {
+func (c *BugCache) EditCommentRaw(author identity.Interface, unixTime int64, target git.Hash, message string, metadata map[string]string) error {
 	op, err := bug.EditComment(c.bug, author, unixTime, target, message)
 	if err != nil {
 		return err

cache/repo_cache.go πŸ”—

@@ -405,7 +405,7 @@ func (c *RepoCache) NewBugWithFiles(title string, message string, files []git.Ha
 // NewBugWithFilesMeta create a new bug with attached files for the message, as
 // well as metadata for the Create operation.
 // The new bug is written in the repository (commit)
-func (c *RepoCache) NewBugRaw(author *identity.Identity, unixTime int64, title string, message string, files []git.Hash, metadata map[string]string) (*BugCache, error) {
+func (c *RepoCache) NewBugRaw(author identity.Interface, unixTime int64, title string, message string, files []git.Hash, metadata map[string]string) (*BugCache, error) {
 	b, op, err := bug.CreateWithFiles(author, unixTime, title, message, files)
 	if err != nil {
 		return nil, err

commands/select/select_test.go πŸ”—

@@ -2,15 +2,16 @@ package _select
 
 import (
 	"testing"
+	"time"
 
 	"github.com/MichaelMure/git-bug/cache"
+	"github.com/MichaelMure/git-bug/identity"
 	"github.com/MichaelMure/git-bug/util/test"
 	"github.com/stretchr/testify/require"
 )
 
 func TestSelect(t *testing.T) {
 	repo := test.CreateRepo(false)
-	defer test.CleanupRepo(repo)
 
 	repoCache, err := cache.NewRepoCache(repo)
 	require.NoError(t, err)
@@ -26,15 +27,18 @@ func TestSelect(t *testing.T) {
 	require.Error(t, err)
 
 	// generate a bunch of bugs
+
+	rene := identity.NewBare("RenΓ© Descartes", "rene@descartes.fr")
+
 	for i := 0; i < 10; i++ {
-		_, err := repoCache.NewBug("title", "message")
+		_, err := repoCache.NewBugRaw(rene, time.Now().Unix(), "title", "message", nil, nil)
 		require.NoError(t, err)
 	}
 
 	// and two more for testing
-	b1, err := repoCache.NewBug("title", "message")
+	b1, err := repoCache.NewBugRaw(rene, time.Now().Unix(), "title", "message", nil, nil)
 	require.NoError(t, err)
-	b2, err := repoCache.NewBug("title", "message")
+	b2, err := repoCache.NewBugRaw(rene, time.Now().Unix(), "title", "message", nil, nil)
 	require.NoError(t, err)
 
 	err = Select(repoCache, b1.Id())
@@ -71,4 +75,6 @@ func TestSelect(t *testing.T) {
 	// Resolve without a pattern should error again after clearing the selected bug
 	_, _, err = ResolveBug(repoCache, []string{})
 	require.Error(t, err)
+
+	require.NoError(t, test.CleanupRepo(repo))
 }

commands/show.go πŸ”—

@@ -42,7 +42,7 @@ func runShowBug(cmd *cobra.Command, args []string) error {
 		case "author":
 			fmt.Printf("%s\n", firstComment.Author.DisplayName())
 		case "authorEmail":
-			fmt.Printf("%s\n", firstComment.Author.Email)
+			fmt.Printf("%s\n", firstComment.Author.Email())
 		case "createTime":
 			fmt.Printf("%s\n", firstComment.FormatTime())
 		case "id":

doc/man/git-bug-id.1 πŸ”—

@@ -1,4 +1,4 @@
-.TH "GIT-BUG" "1" "Jan 2019" "Generated from git-bug's source code" "" 
+.TH "GIT-BUG" "1" "Feb 2019" "Generated from git-bug's source code" "" 
 .nh
 .ad l