diff options
Diffstat (limited to 'bridge')
-rw-r--r-- | bridge/github/import.go | 2 | ||||
-rw-r--r-- | bridge/github/import_test.go | 64 | ||||
-rw-r--r-- | bridge/gitlab/import.go | 1 | ||||
-rw-r--r-- | bridge/gitlab/import_test.go | 72 | ||||
-rw-r--r-- | bridge/jira/import.go | 1 | ||||
-rw-r--r-- | bridge/launchpad/import.go | 1 |
6 files changed, 73 insertions, 68 deletions
diff --git a/bridge/github/import.go b/bridge/github/import.go index e8a4d3cb..af62746f 100644 --- a/bridge/github/import.go +++ b/bridge/github/import.go @@ -551,6 +551,7 @@ func (gi *githubImporter) ensurePerson(repo *cache.RepoCache, actor *actor) (*ca email, string(actor.Login), string(actor.AvatarUrl), + nil, map[string]string{ metaKeyGithubLogin: string(actor.Login), }, @@ -598,6 +599,7 @@ func (gi *githubImporter) getGhost(repo *cache.RepoCache) (*cache.IdentityCache, "", string(q.User.Login), string(q.User.AvatarUrl), + nil, map[string]string{ metaKeyGithubLogin: string(q.User.Login), }, diff --git a/bridge/github/import_test.go b/bridge/github/import_test.go index 2295806f..3d0004c1 100644 --- a/bridge/github/import_test.go +++ b/bridge/github/import_test.go @@ -7,7 +7,6 @@ import ( "testing" "time" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/MichaelMure/git-bug/bridge/core" @@ -20,7 +19,22 @@ import ( ) func Test_Importer(t *testing.T) { - author := identity.NewIdentity("Michael Muré", "batolettre@gmail.com") + envToken := os.Getenv("GITHUB_TOKEN_PRIVATE") + if envToken == "" { + t.Skip("Env var GITHUB_TOKEN_PRIVATE missing") + } + + repo := repository.CreateGoGitTestRepo(false) + defer repository.CleanupTestRepos(repo) + + backend, err := cache.NewRepoCache(repo) + require.NoError(t, err) + + defer backend.Close() + interrupt.RegisterCleaner(backend.Close) + + author, err := identity.NewIdentity(repo, "Michael Muré", "batolettre@gmail.com") + require.NoError(t, err) tests := []struct { name string @@ -127,20 +141,6 @@ func Test_Importer(t *testing.T) { }, } - repo := repository.CreateGoGitTestRepo(false) - defer repository.CleanupTestRepos(repo) - - backend, err := cache.NewRepoCache(repo) - require.NoError(t, err) - - defer backend.Close() - interrupt.RegisterCleaner(backend.Close) - - envToken := os.Getenv("GITHUB_TOKEN_PRIVATE") - if envToken == "" { - t.Skip("Env var GITHUB_TOKEN_PRIVATE missing") - } - login := "test-identity" author.SetMetadata(metaKeyGithubLogin, login) @@ -178,33 +178,33 @@ func Test_Importer(t *testing.T) { require.NoError(t, err) ops := b.Snapshot().Operations - assert.Len(t, tt.bug.Operations, len(b.Snapshot().Operations)) + require.Len(t, tt.bug.Operations, len(b.Snapshot().Operations)) for i, op := range tt.bug.Operations { require.IsType(t, ops[i], op) switch op.(type) { case *bug.CreateOperation: - assert.Equal(t, op.(*bug.CreateOperation).Title, ops[i].(*bug.CreateOperation).Title) - assert.Equal(t, op.(*bug.CreateOperation).Message, ops[i].(*bug.CreateOperation).Message) - assert.Equal(t, op.(*bug.CreateOperation).Author.Name(), ops[i].(*bug.CreateOperation).Author.Name()) + require.Equal(t, op.(*bug.CreateOperation).Title, ops[i].(*bug.CreateOperation).Title) + require.Equal(t, op.(*bug.CreateOperation).Message, ops[i].(*bug.CreateOperation).Message) + require.Equal(t, op.(*bug.CreateOperation).Author.Name(), ops[i].(*bug.CreateOperation).Author.Name()) case *bug.SetStatusOperation: - assert.Equal(t, op.(*bug.SetStatusOperation).Status, ops[i].(*bug.SetStatusOperation).Status) - assert.Equal(t, op.(*bug.SetStatusOperation).Author.Name(), ops[i].(*bug.SetStatusOperation).Author.Name()) + require.Equal(t, op.(*bug.SetStatusOperation).Status, ops[i].(*bug.SetStatusOperation).Status) + require.Equal(t, op.(*bug.SetStatusOperation).Author.Name(), ops[i].(*bug.SetStatusOperation).Author.Name()) case *bug.SetTitleOperation: - assert.Equal(t, op.(*bug.SetTitleOperation).Was, ops[i].(*bug.SetTitleOperation).Was) - assert.Equal(t, op.(*bug.SetTitleOperation).Title, ops[i].(*bug.SetTitleOperation).Title) - assert.Equal(t, op.(*bug.SetTitleOperation).Author.Name(), ops[i].(*bug.SetTitleOperation).Author.Name()) + require.Equal(t, op.(*bug.SetTitleOperation).Was, ops[i].(*bug.SetTitleOperation).Was) + require.Equal(t, op.(*bug.SetTitleOperation).Title, ops[i].(*bug.SetTitleOperation).Title) + require.Equal(t, op.(*bug.SetTitleOperation).Author.Name(), ops[i].(*bug.SetTitleOperation).Author.Name()) case *bug.LabelChangeOperation: - assert.ElementsMatch(t, op.(*bug.LabelChangeOperation).Added, ops[i].(*bug.LabelChangeOperation).Added) - assert.ElementsMatch(t, op.(*bug.LabelChangeOperation).Removed, ops[i].(*bug.LabelChangeOperation).Removed) - assert.Equal(t, op.(*bug.LabelChangeOperation).Author.Name(), ops[i].(*bug.LabelChangeOperation).Author.Name()) + require.ElementsMatch(t, op.(*bug.LabelChangeOperation).Added, ops[i].(*bug.LabelChangeOperation).Added) + require.ElementsMatch(t, op.(*bug.LabelChangeOperation).Removed, ops[i].(*bug.LabelChangeOperation).Removed) + require.Equal(t, op.(*bug.LabelChangeOperation).Author.Name(), ops[i].(*bug.LabelChangeOperation).Author.Name()) case *bug.AddCommentOperation: - assert.Equal(t, op.(*bug.AddCommentOperation).Message, ops[i].(*bug.AddCommentOperation).Message) - assert.Equal(t, op.(*bug.AddCommentOperation).Author.Name(), ops[i].(*bug.AddCommentOperation).Author.Name()) + require.Equal(t, op.(*bug.AddCommentOperation).Message, ops[i].(*bug.AddCommentOperation).Message) + require.Equal(t, op.(*bug.AddCommentOperation).Author.Name(), ops[i].(*bug.AddCommentOperation).Author.Name()) case *bug.EditCommentOperation: - assert.Equal(t, op.(*bug.EditCommentOperation).Message, ops[i].(*bug.EditCommentOperation).Message) - assert.Equal(t, op.(*bug.EditCommentOperation).Author.Name(), ops[i].(*bug.EditCommentOperation).Author.Name()) + require.Equal(t, op.(*bug.EditCommentOperation).Message, ops[i].(*bug.EditCommentOperation).Message) + require.Equal(t, op.(*bug.EditCommentOperation).Author.Name(), ops[i].(*bug.EditCommentOperation).Author.Name()) default: panic("unknown operation type") diff --git a/bridge/gitlab/import.go b/bridge/gitlab/import.go index cf4f0039..7939f4e4 100644 --- a/bridge/gitlab/import.go +++ b/bridge/gitlab/import.go @@ -406,6 +406,7 @@ func (gi *gitlabImporter) ensurePerson(repo *cache.RepoCache, id int) (*cache.Id user.PublicEmail, user.Username, user.AvatarURL, + nil, map[string]string{ // because Gitlab metaKeyGitlabId: strconv.Itoa(id), diff --git a/bridge/gitlab/import_test.go b/bridge/gitlab/import_test.go index db550f08..7e47e149 100644 --- a/bridge/gitlab/import_test.go +++ b/bridge/gitlab/import_test.go @@ -7,7 +7,6 @@ import ( "testing" "time" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/MichaelMure/git-bug/bridge/core" @@ -20,7 +19,27 @@ import ( ) func TestImport(t *testing.T) { - author := identity.NewIdentity("Amine Hilaly", "hilalyamine@gmail.com") + envToken := os.Getenv("GITLAB_API_TOKEN") + if envToken == "" { + t.Skip("Env var GITLAB_API_TOKEN missing") + } + + projectID := os.Getenv("GITLAB_PROJECT_ID") + if projectID == "" { + t.Skip("Env var GITLAB_PROJECT_ID missing") + } + + repo := repository.CreateGoGitTestRepo(false) + defer repository.CleanupTestRepos(repo) + + backend, err := cache.NewRepoCache(repo) + require.NoError(t, err) + + defer backend.Close() + interrupt.RegisterCleaner(backend.Close) + + author, err := identity.NewIdentity(repo, "Amine Hilaly", "hilalyamine@gmail.com") + require.NoError(t, err) tests := []struct { name string @@ -76,25 +95,6 @@ func TestImport(t *testing.T) { }, } - repo := repository.CreateGoGitTestRepo(false) - defer repository.CleanupTestRepos(repo) - - backend, err := cache.NewRepoCache(repo) - require.NoError(t, err) - - defer backend.Close() - interrupt.RegisterCleaner(backend.Close) - - envToken := os.Getenv("GITLAB_API_TOKEN") - if envToken == "" { - t.Skip("Env var GITLAB_API_TOKEN missing") - } - - projectID := os.Getenv("GITLAB_PROJECT_ID") - if projectID == "" { - t.Skip("Env var GITLAB_PROJECT_ID missing") - } - login := "test-identity" author.SetMetadata(metaKeyGitlabLogin, login) @@ -141,26 +141,26 @@ func TestImport(t *testing.T) { switch op.(type) { case *bug.CreateOperation: - assert.Equal(t, op.(*bug.CreateOperation).Title, ops[i].(*bug.CreateOperation).Title) - assert.Equal(t, op.(*bug.CreateOperation).Message, ops[i].(*bug.CreateOperation).Message) - assert.Equal(t, op.(*bug.CreateOperation).Author.Name(), ops[i].(*bug.CreateOperation).Author.Name()) + require.Equal(t, op.(*bug.CreateOperation).Title, ops[i].(*bug.CreateOperation).Title) + require.Equal(t, op.(*bug.CreateOperation).Message, ops[i].(*bug.CreateOperation).Message) + require.Equal(t, op.(*bug.CreateOperation).Author.Name(), ops[i].(*bug.CreateOperation).Author.Name()) case *bug.SetStatusOperation: - assert.Equal(t, op.(*bug.SetStatusOperation).Status, ops[i].(*bug.SetStatusOperation).Status) - assert.Equal(t, op.(*bug.SetStatusOperation).Author.Name(), ops[i].(*bug.SetStatusOperation).Author.Name()) + require.Equal(t, op.(*bug.SetStatusOperation).Status, ops[i].(*bug.SetStatusOperation).Status) + require.Equal(t, op.(*bug.SetStatusOperation).Author.Name(), ops[i].(*bug.SetStatusOperation).Author.Name()) case *bug.SetTitleOperation: - assert.Equal(t, op.(*bug.SetTitleOperation).Was, ops[i].(*bug.SetTitleOperation).Was) - assert.Equal(t, op.(*bug.SetTitleOperation).Title, ops[i].(*bug.SetTitleOperation).Title) - assert.Equal(t, op.(*bug.SetTitleOperation).Author.Name(), ops[i].(*bug.SetTitleOperation).Author.Name()) + require.Equal(t, op.(*bug.SetTitleOperation).Was, ops[i].(*bug.SetTitleOperation).Was) + require.Equal(t, op.(*bug.SetTitleOperation).Title, ops[i].(*bug.SetTitleOperation).Title) + require.Equal(t, op.(*bug.SetTitleOperation).Author.Name(), ops[i].(*bug.SetTitleOperation).Author.Name()) case *bug.LabelChangeOperation: - assert.ElementsMatch(t, op.(*bug.LabelChangeOperation).Added, ops[i].(*bug.LabelChangeOperation).Added) - assert.ElementsMatch(t, op.(*bug.LabelChangeOperation).Removed, ops[i].(*bug.LabelChangeOperation).Removed) - assert.Equal(t, op.(*bug.LabelChangeOperation).Author.Name(), ops[i].(*bug.LabelChangeOperation).Author.Name()) + require.ElementsMatch(t, op.(*bug.LabelChangeOperation).Added, ops[i].(*bug.LabelChangeOperation).Added) + require.ElementsMatch(t, op.(*bug.LabelChangeOperation).Removed, ops[i].(*bug.LabelChangeOperation).Removed) + require.Equal(t, op.(*bug.LabelChangeOperation).Author.Name(), ops[i].(*bug.LabelChangeOperation).Author.Name()) case *bug.AddCommentOperation: - assert.Equal(t, op.(*bug.AddCommentOperation).Message, ops[i].(*bug.AddCommentOperation).Message) - assert.Equal(t, op.(*bug.AddCommentOperation).Author.Name(), ops[i].(*bug.AddCommentOperation).Author.Name()) + require.Equal(t, op.(*bug.AddCommentOperation).Message, ops[i].(*bug.AddCommentOperation).Message) + require.Equal(t, op.(*bug.AddCommentOperation).Author.Name(), ops[i].(*bug.AddCommentOperation).Author.Name()) case *bug.EditCommentOperation: - assert.Equal(t, op.(*bug.EditCommentOperation).Message, ops[i].(*bug.EditCommentOperation).Message) - assert.Equal(t, op.(*bug.EditCommentOperation).Author.Name(), ops[i].(*bug.EditCommentOperation).Author.Name()) + require.Equal(t, op.(*bug.EditCommentOperation).Message, ops[i].(*bug.EditCommentOperation).Message) + require.Equal(t, op.(*bug.EditCommentOperation).Author.Name(), ops[i].(*bug.EditCommentOperation).Author.Name()) default: panic("unknown operation type") diff --git a/bridge/jira/import.go b/bridge/jira/import.go index b66b0fa3..00148bb6 100644 --- a/bridge/jira/import.go +++ b/bridge/jira/import.go @@ -196,6 +196,7 @@ func (ji *jiraImporter) ensurePerson(repo *cache.RepoCache, user User) (*cache.I user.EmailAddress, user.Key, "", + nil, map[string]string{ metaKeyJiraUser: user.Key, }, diff --git a/bridge/launchpad/import.go b/bridge/launchpad/import.go index ce50828b..6b5667ba 100644 --- a/bridge/launchpad/import.go +++ b/bridge/launchpad/import.go @@ -35,6 +35,7 @@ func (li *launchpadImporter) ensurePerson(repo *cache.RepoCache, owner LPPerson) "", owner.Login, "", + nil, map[string]string{ metaKeyLaunchpadLogin: owner.Login, }, |