(t *testing.T)
| 34 | ) |
| 35 | |
| 36 | func 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", |
nothing calls this directly
no test coverage detected