MCPcopy
hub / github.com/apache/devlake / TestRepoDataFlow

Function TestRepoDataFlow

backend/plugins/bitbucket/e2e/repo_test.go:36–122  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

34)
35
36func TestRepoDataFlow(t *testing.T) {
37 var plugin impl.Bitbucket
38 dataflowTester := e2ehelper.NewDataFlowTester(t, "bitbucket", plugin)
39
40 taskData := &tasks.BitbucketTaskData{
41 Options: &tasks.BitbucketOptions{
42 ConnectionId: 1,
43 FullName: "likyh/likyhphp",
44 },
45 }
46
47 // import raw data table
48 csvIter, _ := pluginhelper.NewCsvFileIterator("./raw_tables/_raw_bitbucket_api_repositories.csv")
49 defer csvIter.Close()
50 apiRepo := &models.BitbucketApiRepo{}
51 // load rows and insert into target table
52 for csvIter.HasNext() {
53 toInsertValues := csvIter.Fetch()
54 data := json.RawMessage(toInsertValues[`data`].(string))
55 err := errors.Convert(json.Unmarshal(data, apiRepo))
56 assert.Nil(t, err)
57 break
58 }
59
60 // verify extraction
61 dataflowTester.FlushTabler(&models.BitbucketRepo{})
62 scope := apiRepo.ConvertApiScope()
63 scope.ConnectionId = 1
64 err := dataflowTester.Dal.CreateIfNotExist(scope)
65 assert.Nil(t, err)
66 dataflowTester.VerifyTable(
67 models.BitbucketRepo{},
68 "./snapshot_tables/_tool_bitbucket_repos.csv",
69 e2ehelper.ColumnWithRawData(
70 "connection_id",
71 "bitbucket_id",
72 "name",
73 "html_url",
74 "description",
75 "owner",
76 "language",
77 "clone_url",
78 ),
79 )
80
81 // verify extraction
82 dataflowTester.FlushTabler(&code.Repo{})
83 dataflowTester.FlushTabler(&ticket.Board{})
84 dataflowTester.FlushTabler(&devops.CicdScope{})
85 dataflowTester.Subtask(tasks.ConvertRepoMeta, taskData)
86 dataflowTester.VerifyTable(
87 code.Repo{},
88 "./snapshot_tables/repos.csv",
89 e2ehelper.ColumnWithRawData(
90 "id",
91 "name",
92 "url",
93 "description",

Callers

nothing calls this directly

Calls 9

CloseMethod · 0.95
HasNextMethod · 0.95
FetchMethod · 0.95
FlushTablerMethod · 0.95
ConvertApiScopeMethod · 0.95
VerifyTableMethod · 0.95
SubtaskMethod · 0.95
CreateIfNotExistMethod · 0.65
ConvertMethod · 0.45

Tested by

no test coverage detected