| /* |
| Licensed to the Apache Software Foundation (ASF) under one or more |
| contributor license agreements. See the NOTICE file distributed with |
| this work for additional information regarding copyright ownership. |
| The ASF licenses this file to You under the Apache License, Version 2.0 |
| (the "License"); you may not use this file except in compliance with |
| the License. You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
| */ |
| |
| package e2e |
| |
| import ( |
| "testing" |
| |
| "github.com/apache/incubator-devlake/core/models/domainlayer/ticket" |
| "github.com/apache/incubator-devlake/helpers/e2ehelper" |
| "github.com/apache/incubator-devlake/plugins/github/impl" |
| "github.com/apache/incubator-devlake/plugins/github/models" |
| "github.com/apache/incubator-devlake/plugins/github/tasks" |
| ) |
| |
| func TestIssueDataFlow(t *testing.T) { |
| var plugin impl.Github |
| dataflowTester := e2ehelper.NewDataFlowTester(t, "github", plugin) |
| |
| taskData := &tasks.GithubTaskData{ |
| Options: &tasks.GithubOptions{ |
| ConnectionId: 1, |
| Name: "panjf2000/ants", |
| GithubId: 134018330, |
| ScopeConfig: &models.GithubScopeConfig{ |
| PrType: "type/(.*)$", |
| PrComponent: "component/(.*)$", |
| PrBodyClosePattern: "(?mi)(fix|close|resolve|fixes|closes|resolves|fixed|closed|resolved)[\\s]*.*(((and )?(#|https:\\/\\/github.com\\/%s\\/issues\\/)\\d+[ ]*)+)", |
| IssueSeverity: "severity/(.*)$", |
| IssuePriority: "^(highest|high|medium|low)$", |
| IssueComponent: "component/(.*)$", |
| IssueTypeBug: "^(bug|failure|error)$", |
| IssueTypeIncident: "", |
| IssueTypeRequirement: "^(feat|feature|proposal|requirement)$", |
| }, |
| }, |
| } |
| |
| // import raw data table |
| dataflowTester.ImportCsvIntoRawTable("./raw_tables/_raw_github_api_issues.csv", "_raw_github_api_issues") |
| |
| // verify issue extraction |
| dataflowTester.FlushTabler(&models.GithubIssue{}) |
| dataflowTester.FlushTabler(&models.GithubIssueLabel{}) |
| dataflowTester.FlushTabler(&models.GithubRepoAccount{}) |
| dataflowTester.FlushTabler(&models.GithubIssueAssignee{}) |
| dataflowTester.Subtask(tasks.ExtractApiIssuesMeta, taskData) |
| dataflowTester.VerifyTable( |
| models.GithubIssue{}, |
| "./snapshot_tables/_tool_github_issues.csv", |
| []string{ |
| "connection_id", |
| "github_id", |
| "repo_id", |
| "number", |
| "state", |
| "title", |
| "body", |
| "priority", |
| "type", |
| "author_id", |
| "author_name", |
| "assignee_id", |
| "assignee_name", |
| "milestone_id", |
| "lead_time_minutes", |
| "url", |
| "closed_at", |
| "github_created_at", |
| "github_updated_at", |
| "severity", |
| "component", |
| "_raw_data_params", |
| "_raw_data_table", |
| "_raw_data_id", |
| "_raw_data_remark", |
| }, |
| ) |
| dataflowTester.VerifyTable( |
| models.GithubIssueLabel{}, |
| "./snapshot_tables/_tool_github_issue_labels.csv", |
| []string{ |
| "connection_id", |
| "issue_id", |
| "label_name", |
| "_raw_data_params", |
| "_raw_data_table", |
| "_raw_data_id", |
| "_raw_data_remark", |
| }, |
| ) |
| dataflowTester.VerifyTable( |
| models.GithubRepoAccount{}, |
| "./snapshot_tables/_tool_github_accounts_in_issue.csv", |
| []string{ |
| "connection_id", |
| "account_id", |
| "repo_github_id", |
| "login", |
| "_raw_data_params", |
| "_raw_data_table", |
| "_raw_data_id", |
| "_raw_data_remark", |
| }, |
| ) |
| |
| // verify issue conversion |
| dataflowTester.FlushTabler(&ticket.Issue{}) |
| dataflowTester.FlushTabler(&ticket.BoardIssue{}) |
| dataflowTester.Subtask(tasks.ConvertIssuesMeta, taskData) |
| dataflowTester.VerifyTable( |
| ticket.Issue{}, |
| "./snapshot_tables/issues.csv", |
| []string{ |
| "id", |
| "url", |
| "icon_url", |
| "issue_key", |
| "title", |
| "description", |
| "epic_key", |
| "type", |
| "status", |
| "original_status", |
| "story_point", |
| "resolution_date", |
| "created_date", |
| "updated_date", |
| "lead_time_minutes", |
| "parent_issue_id", |
| "priority", |
| "original_estimate_minutes", |
| "time_spent_minutes", |
| "time_remaining_minutes", |
| "creator_id", |
| "creator_name", |
| "assignee_id", |
| "assignee_name", |
| "severity", |
| "component", |
| "_raw_data_params", |
| "_raw_data_table", |
| "_raw_data_id", |
| "_raw_data_remark", |
| }, |
| ) |
| dataflowTester.VerifyTable( |
| ticket.BoardIssue{}, |
| "./snapshot_tables/board_issues.csv", |
| []string{ |
| "board_id", |
| "issue_id", |
| "_raw_data_params", |
| "_raw_data_table", |
| "_raw_data_id", |
| "_raw_data_remark", |
| }, |
| ) |
| |
| // verify issue labels conversion |
| dataflowTester.FlushTabler(&ticket.IssueLabel{}) |
| dataflowTester.Subtask(tasks.ConvertIssueLabelsMeta, taskData) |
| dataflowTester.VerifyTable( |
| ticket.IssueLabel{}, |
| "./snapshot_tables/issue_labels.csv", |
| []string{ |
| "issue_id", |
| "label_name", |
| "_raw_data_params", |
| "_raw_data_table", |
| "_raw_data_id", |
| "_raw_data_remark", |
| }, |
| ) |
| } |