You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by wa...@apache.org on 2022/06/15 07:56:30 UTC
[incubator-devlake] 03/12: use updated e2e test helper to update gitlab e2e test
This is an automated email from the ASF dual-hosted git repository.
warren pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
commit d7feca9d81580fd20c227ded4057f96c31da54d9
Author: linyh <ya...@meri.co>
AuthorDate: Tue Jun 14 22:42:29 2022 +0800
use updated e2e test helper to update gitlab e2e test
---
helpers/e2ehelper/data_flow_tester.go | 1 -
plugins/gitlab/e2e/project_test.go | 20 ++++++++++++--------
.../gitlab/e2e/tables/_raw_gitlab_api_projects.csv | 16 ----------------
plugins/gitlab/e2e/tables/_tool_gitlab_projects.csv | 20 ++------------------
plugins/gitlab/e2e/tables/repos.csv | 20 ++------------------
plugins/gitlab/tasks/project_convertor.go | 2 +-
6 files changed, 17 insertions(+), 62 deletions(-)
diff --git a/helpers/e2ehelper/data_flow_tester.go b/helpers/e2ehelper/data_flow_tester.go
index 20625013..e5f1cbf0 100644
--- a/helpers/e2ehelper/data_flow_tester.go
+++ b/helpers/e2ehelper/data_flow_tester.go
@@ -246,7 +246,6 @@ func (t *DataFlowTester) VerifyTable(dst schema.Tabler, csvRelPath string, pkfie
for _, field := range targetfields {
actualValue := ""
switch actual[field].(type) {
- // TODO: ensure testing database is in UTC timezone
case time.Time:
if actual[field] != nil {
actualValue = actual[field].(time.Time).In(location).Format("2006-01-02T15:04:05.000-07:00")
diff --git a/plugins/gitlab/e2e/project_test.go b/plugins/gitlab/e2e/project_test.go
index 32a7f02b..7e12c03e 100644
--- a/plugins/gitlab/e2e/project_test.go
+++ b/plugins/gitlab/e2e/project_test.go
@@ -21,7 +21,9 @@ import (
"testing"
"github.com/apache/incubator-devlake/helpers/e2ehelper"
+ "github.com/apache/incubator-devlake/models/domainlayer/code"
"github.com/apache/incubator-devlake/plugins/gitlab/impl"
+ "github.com/apache/incubator-devlake/plugins/gitlab/models"
"github.com/apache/incubator-devlake/plugins/gitlab/tasks"
)
@@ -32,20 +34,22 @@ func TestGitlabDataFlow(t *testing.T) {
taskData := &tasks.GitlabTaskData{
Options: &tasks.GitlabOptions{
- ProjectId: 3472737,
+ ConnectionId: 1,
+ ProjectId: 3472737,
},
}
// import raw data table
+ dataflowTester.MigrateRawTableAndFlush("_raw_gitlab_api_project")
dataflowTester.ImportCsv("./tables/_raw_gitlab_api_projects.csv", "_raw_gitlab_api_project")
// verify extraction
- dataflowTester.FlushTable("_tool_gitlab_projects")
+ dataflowTester.MigrateTableAndFlush(&models.GitlabProject{})
dataflowTester.Subtask(tasks.ExtractProjectMeta, taskData)
- dataflowTester.VerifyTable(
- "_tool_gitlab_projects",
+ dataflowTester.CreateSnapshotOrVerify(
+ models.GitlabProject{},
"tables/_tool_gitlab_projects.csv",
- []string{"gitlab_id"},
+ []string{"connection_id", "gitlab_id"},
[]string{
"name",
"description",
@@ -68,10 +72,10 @@ func TestGitlabDataFlow(t *testing.T) {
)
// verify conversion
- dataflowTester.FlushTable("repos")
+ dataflowTester.MigrateTableAndFlush(&code.Repo{})
dataflowTester.Subtask(tasks.ConvertProjectMeta, taskData)
- dataflowTester.VerifyTable(
- "repos",
+ dataflowTester.CreateSnapshotOrVerify(
+ code.Repo{},
"tables/repos.csv",
[]string{"id"},
[]string{
diff --git a/plugins/gitlab/e2e/tables/_raw_gitlab_api_projects.csv b/plugins/gitlab/e2e/tables/_raw_gitlab_api_projects.csv
index b9fef1bb..9b5559c3 100644
--- a/plugins/gitlab/e2e/tables/_raw_gitlab_api_projects.csv
+++ b/plugins/gitlab/e2e/tables/_raw_gitlab_api_projects.csv
@@ -1,18 +1,2 @@
-#
-# 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.
-#
"id","params","data","url","input","created_at"
2,"{""ProjectId"":3472737}","{""id"": 3472737, ""name"": ""inkscape"", ""path"": ""inkscape"", ""_links"": {""self"": ""https://gitlab.com/api/v4/projects/3472737"", ""events"": ""https://gitlab.com/api/v4/projects/3472737/events"", ""issues"": ""https://gitlab.com/api/v4/projects/3472737/issues"", ""labels"": ""https://gitlab.com/api/v4/projects/3472737/labels"", ""members"": ""https://gitlab.com/api/v4/projects/3472737/members"", ""repo_branches"": ""https://gitlab.com/api/v4/projects/ [...]
diff --git a/plugins/gitlab/e2e/tables/_tool_gitlab_projects.csv b/plugins/gitlab/e2e/tables/_tool_gitlab_projects.csv
index fd30a417..4c8690a9 100644
--- a/plugins/gitlab/e2e/tables/_tool_gitlab_projects.csv
+++ b/plugins/gitlab/e2e/tables/_tool_gitlab_projects.csv
@@ -1,18 +1,2 @@
-#
-# 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.
-#
-"gitlab_id","name","description","default_branch","path_with_namespace","web_url","creator_id","visibility","open_issues_count","star_count","forked_from_project_id","forked_from_project_web_url","created_date","updated_date","created_at","updated_at","_raw_data_params","_raw_data_table","_raw_data_id","_raw_data_remark"
-3472737,inkscape,Inkscape vector image editor,master,inkscape/inkscape,https://gitlab.com/inkscape/inkscape,0,public,1472,2627,0,"","2017-06-09 14:16:35.615000000","2022-05-05 08:26:20.527000000","2022-05-05 09:38:23.184000000","2022-05-05 09:38:23.184000000","{""ProjectId"":3472737}",_raw_gitlab_api_project,2,""
+connection_id,gitlab_id,name,description,default_branch,path_with_namespace,web_url,creator_id,visibility,open_issues_count,star_count,forked_from_project_id,forked_from_project_web_url,created_date,updated_date,_raw_data_params,_raw_data_table,_raw_data_id,_raw_data_remark
+0,3472737,inkscape,Inkscape vector image editor,master,inkscape/inkscape,https://gitlab.com/inkscape/inkscape,0,public,1472,2627,0,,2017-06-09T14:16:35.615+00:00,2022-05-05T08:26:20.527+00:00,"{""ProjectId"":3472737}",_raw_gitlab_api_project,2,
diff --git a/plugins/gitlab/e2e/tables/repos.csv b/plugins/gitlab/e2e/tables/repos.csv
index f392403d..0ec8467f 100644
--- a/plugins/gitlab/e2e/tables/repos.csv
+++ b/plugins/gitlab/e2e/tables/repos.csv
@@ -1,18 +1,2 @@
-#
-# 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.
-#
-"id","created_at","updated_at","_raw_data_params","_raw_data_table","_raw_data_id","_raw_data_remark","name","url","description","owner_id","language","forked_from","created_date","updated_date","deleted"
-gitlab:GitlabProject:3472737,"2022-05-05 09:56:43.438000000","2022-05-05 09:56:43.438000000","{""ProjectId"":3472737}",_raw_gitlab_api_project,2,"",inkscape,https://gitlab.com/inkscape/inkscape,Inkscape vector image editor,"","","","2017-06-09 14:16:35.615000000","2022-05-05 08:26:20.527000000",0
+id,_raw_data_params,_raw_data_table,_raw_data_id,_raw_data_remark,name,url,description,owner_id,language,forked_from,created_date,updated_date,deleted
+gitlab:GitlabProject:0:3472737,"{""ProjectId"":3472737}",_raw_gitlab_api_project,2,,inkscape,https://gitlab.com/inkscape/inkscape,Inkscape vector image editor,,,,2017-06-09T14:16:35.615+00:00,2022-05-05T08:26:20.527+00:00,0
diff --git a/plugins/gitlab/tasks/project_convertor.go b/plugins/gitlab/tasks/project_convertor.go
index f191ea3c..2b32bbf5 100644
--- a/plugins/gitlab/tasks/project_convertor.go
+++ b/plugins/gitlab/tasks/project_convertor.go
@@ -98,7 +98,7 @@ func convertProject(gitlabApiProject *GitlabApiProject) *models.GitlabProject {
func convertToRepositoryModel(project *models.GitlabProject) *code.Repo {
domainRepository := &code.Repo{
DomainEntity: domainlayer.DomainEntity{
- Id: didgen.NewDomainIdGenerator(project).Generate(project.GitlabId),
+ Id: didgen.NewDomainIdGenerator(project).Generate(project.ConnectionId, project.GitlabId),
},
Name: project.Name,
Url: project.WebUrl,