MCPcopy Index your code
hub / github.com/git-bug/git-bug / TestGithubImporterIntegration

Function TestGithubImporterIntegration

bridge/github/import_integration_test.go:29–76  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

27var edited = githubv4.String("edited")
28
29func TestGithubImporterIntegration(t *testing.T) {
30 // mock
31 clientMock := &mocks.Client{}
32 setupExpectations(t, clientMock)
33 importer := githubImporter{}
34 importer.client = &rateLimitHandlerClient{sc: clientMock}
35
36 // arrange
37 repo := repository.CreateGoGitTestRepo(t, false)
38 backend, err := cache.NewRepoCacheNoEvents(repo)
39 require.NoError(t, err)
40
41 defer backend.Close()
42 interrupt.RegisterCleaner(backend.Close)
43 require.NoError(t, err)
44
45 // act
46 events, err := importer.ImportAll(context.Background(), backend, time.Time{})
47
48 // assert
49 require.NoError(t, err)
50 for e := range events {
51 require.NoError(t, e.Err)
52 }
53 require.Len(t, backend.Bugs().AllIds(), 5)
54 require.Len(t, backend.Identities().AllIds(), 2)
55
56 b1, err := backend.Bugs().ResolveBugCreateMetadata(metaKeyGithubUrl, "https://github.com/marcus/to-himself/issues/1")
57 require.NoError(t, err)
58 ops1 := b1.Snapshot().Operations
59 require.Equal(t, "marcus", ops1[0].Author().Name())
60 require.Equal(t, "title 1", ops1[0].(*bug.CreateOperation).Title)
61 require.Equal(t, "body text 1", ops1[0].(*bug.CreateOperation).Message)
62
63 b3, err := backend.Bugs().ResolveBugCreateMetadata(metaKeyGithubUrl, "https://github.com/marcus/to-himself/issues/3")
64 require.NoError(t, err)
65 ops3 := b3.Snapshot().Operations
66 require.Equal(t, "issue 3 comment 1", ops3[1].(*bug.AddCommentOperation).Message)
67 require.Equal(t, "issue 3 comment 2", ops3[2].(*bug.AddCommentOperation).Message)
68 require.Equal(t, []common.Label{"bug"}, ops3[3].(*bug.LabelChangeOperation).Added)
69 require.Equal(t, "title 3, edit 1", ops3[4].(*bug.SetTitleOperation).Title)
70
71 b4, err := backend.Bugs().ResolveBugCreateMetadata(metaKeyGithubUrl, "https://github.com/marcus/to-himself/issues/4")
72 require.NoError(t, err)
73 ops4 := b4.Snapshot().Operations
74 require.Equal(t, "edited", ops4[1].(*bug.EditCommentOperation).Message)
75
76}
77
78func setupExpectations(t *testing.T, mock *mocks.Client) {
79 rateLimitingError(mock)

Callers

nothing calls this directly

Calls 14

ImportAllMethod · 0.95
CreateGoGitTestRepoFunction · 0.92
NewRepoCacheNoEventsFunction · 0.92
RegisterCleanerFunction · 0.92
setupExpectationsFunction · 0.85
AllIdsMethod · 0.80
BugsMethod · 0.80
IdentitiesMethod · 0.80
SnapshotMethod · 0.80
CloseMethod · 0.65
NameMethod · 0.65

Tested by

no test coverage detected