aboutsummaryrefslogtreecommitdiffstats
path: root/bridge/github
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2021-04-09 13:01:14 +0200
committerMichael Muré <batolettre@gmail.com>2021-04-09 13:01:14 +0200
commit1520f678f7a2bc6e01d9b01df5ce49f2f46be7d7 (patch)
treef6d71c1f29cf06ccab9e4ae434b19ab17caa4385 /bridge/github
parent0fd570171d171aa574d7f01d6033a9c01d668465 (diff)
parentbc5f618eba812859bf87ce2c31b278bd518d4555 (diff)
downloadgit-bug-1520f678f7a2bc6e01d9b01df5ce49f2f46be7d7.tar.gz
Merge remote-tracking branch 'origin/master' into dev-gh-bridge
Diffstat (limited to 'bridge/github')
-rw-r--r--bridge/github/export.go2
-rw-r--r--bridge/github/export_test.go2
-rw-r--r--bridge/github/import.go2
-rw-r--r--bridge/github/import_test.go63
4 files changed, 33 insertions, 36 deletions
diff --git a/bridge/github/export.go b/bridge/github/export.go
index 57b52ee0..1a59fbb3 100644
--- a/bridge/github/export.go
+++ b/bridge/github/export.go
@@ -294,7 +294,7 @@ func (ge *githubExporter) exportBug(ctx context.Context, b *cache.BugCache, out
continue
}
- opAuthor := op.GetAuthor()
+ opAuthor := op.Author()
client, err := ge.getClientForIdentity(opAuthor.Id())
if err != nil {
continue
diff --git a/bridge/github/export_test.go b/bridge/github/export_test.go
index 5b9a3495..b7a36bcf 100644
--- a/bridge/github/export_test.go
+++ b/bridge/github/export_test.go
@@ -126,7 +126,7 @@ func testCases(t *testing.T, repo *cache.RepoCache) []*testCase {
}
}
-func TestPushPull(t *testing.T) {
+func TestGithubPushPull(t *testing.T) {
// repo owner
envUser := os.Getenv("GITHUB_TEST_USER")
diff --git a/bridge/github/import.go b/bridge/github/import.go
index e89f34c4..47be6374 100644
--- a/bridge/github/import.go
+++ b/bridge/github/import.go
@@ -543,6 +543,7 @@ func (gi *githubImporter) ensurePerson(ctx context.Context, repo *cache.RepoCach
email,
string(actor.Login),
string(actor.AvatarUrl),
+ nil,
map[string]string{
metaKeyGithubLogin: string(actor.Login),
},
@@ -576,6 +577,7 @@ func (gi *githubImporter) getGhost(ctx context.Context, repo *cache.RepoCache) (
"",
string(user.Login),
string(user.AvatarUrl),
+ nil,
map[string]string{
metaKeyGithubLogin: string(user.Login),
},
diff --git a/bridge/github/import_test.go b/bridge/github/import_test.go
index 2295806f..324d5421 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"
@@ -19,8 +18,23 @@ import (
"github.com/MichaelMure/git-bug/util/interrupt"
)
-func Test_Importer(t *testing.T) {
- author := identity.NewIdentity("Michael Muré", "batolettre@gmail.com")
+func TestGithubImporter(t *testing.T) {
+ 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,28 @@ 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)
+ require.Equal(t, op.Author().Name(), ops[i].Author().Name())
- switch op.(type) {
+ switch op := 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.Title, ops[i].(*bug.CreateOperation).Title)
+ require.Equal(t, op.Message, ops[i].(*bug.CreateOperation).Message)
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.Status, ops[i].(*bug.SetStatusOperation).Status)
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.Was, ops[i].(*bug.SetTitleOperation).Was)
+ require.Equal(t, op.Title, ops[i].(*bug.SetTitleOperation).Title)
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.Added, ops[i].(*bug.LabelChangeOperation).Added)
+ require.ElementsMatch(t, op.Removed, ops[i].(*bug.LabelChangeOperation).Removed)
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.Message, ops[i].(*bug.AddCommentOperation).Message)
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.Message, ops[i].(*bug.EditCommentOperation).Message)
default:
panic("unknown operation type")