From 2b59b8cb375e7193a190883f8b3f029d9feb4fc2 Mon Sep 17 00:00:00 2001 From: Sam Lucidi Date: Wed, 8 Nov 2023 08:47:47 -0500 Subject: [PATCH] Add contributors/owner to import API tests Signed-off-by: Sam Lucidi --- test/api/importcsv/api_test.go | 20 ++++++++++++++--- test/api/importcsv/samples.go | 22 +++++++++++++++++++ .../importcsv/template_application_import.csv | 8 +++---- 3 files changed, 43 insertions(+), 7 deletions(-) diff --git a/test/api/importcsv/api_test.go b/test/api/importcsv/api_test.go index 3e7776ec1..8e7596fc8 100644 --- a/test/api/importcsv/api_test.go +++ b/test/api/importcsv/api_test.go @@ -1,13 +1,13 @@ package importcsv import ( + "github.com/konveyor/tackle2-hub/api" + "github.com/konveyor/tackle2-hub/binding" + "github.com/konveyor/tackle2-hub/test/assert" "io/ioutil" "os" "testing" "time" - "github.com/konveyor/tackle2-hub/api" - "github.com/konveyor/tackle2-hub/binding" - "github.com/konveyor/tackle2-hub/test/assert" ) func TestImportCSV(t *testing.T) { @@ -68,6 +68,20 @@ func TestImportCSV(t *testing.T) { if r.ExpectedApplications[i].BusinessService.Name != gotApp.BusinessService.Name { t.Errorf("Mismatch in name of the BusinessService of imported Application: Expected %s, Actual %s", r.ExpectedApplications[i].BusinessService.Name, gotApp.BusinessService.Name) } + if gotApp.Owner == nil || r.ExpectedApplications[i].Owner == nil { + if gotApp.Owner != r.ExpectedApplications[i].Owner { + t.Errorf("Mismatch in value of Owner on imported Application: Expected %v, Actual %v", r.ExpectedApplications[i].Owner, gotApp.BusinessService) + } + } else if r.ExpectedApplications[i].Owner.Name != gotApp.Owner.Name { + t.Errorf("Mismatch in name of the Owner of imported Application: Expected %s, Actual %s", r.ExpectedApplications[i].Owner.Name, gotApp.BusinessService.Name) + } + if len(gotApp.Contributors) != len(r.ExpectedApplications[i].Contributors) { + t.Errorf("Mismatch in number of Contributors: Expected %d, Actual %d", len(r.ExpectedApplications[i].Contributors), len(gotApp.Contributors)) + } else { + for j, contributor := range gotApp.Contributors { + if contributor.Name != r.ExpectedApplications[i].Contributors[j].Name {} + } + } } } diff --git a/test/api/importcsv/samples.go b/test/api/importcsv/samples.go index 56ee10628..aa0423fc9 100644 --- a/test/api/importcsv/samples.go +++ b/test/api/importcsv/samples.go @@ -48,6 +48,9 @@ var ( BusinessService: &api.Ref{ Name: "Retail", }, + Owner: &api.Ref{ + Name: "John Doe", + }, }, { Name: "Inventory", @@ -82,6 +85,14 @@ var ( BusinessService: &api.Ref{ Name: "Retail", }, + Contributors: []api.Ref{ + { + Name: "John Doe", + }, + { + Name: "Jane Smith", + }, + }, }, { Name: "Gateway", @@ -112,6 +123,17 @@ var ( BusinessService: &api.Ref{ Name: "Retail", }, + Owner: &api.Ref{ + Name: "John Doe", + }, + Contributors: []api.Ref{ + { + Name: "John Doe", + }, + { + Name: "Jane Smith", + }, + }, }, }, ExpectedDependencies: []api.Dependency{ diff --git a/test/api/importcsv/template_application_import.csv b/test/api/importcsv/template_application_import.csv index 80f64fdab..0466d30cd 100644 --- a/test/api/importcsv/template_application_import.csv +++ b/test/api/importcsv/template_application_import.csv @@ -1,6 +1,6 @@ -Record Type 1,Application Name,Description,Comments,Business Service,Dependency,Dependency Direction,Binary Group,Binary Artifact,Binary Version,Binary Packaging,Repository Type,Repository URL,Repository Branch,Repository Path,Tag Category 1,Tag 1,Tag Category 2,Tag 2,Tag Category 3,Tag 3,Tag Category 4,Tag 4,Tag Category 5,Tag 5,Tag Category 6,Tag 6,Tag Category 7,Tag 7,Tag Category 8,Tag 8,Tag Category 9,Tag 9,Tag Category 10,Tag 10,Tag Category 11,Tag 11,Tag Category 12,Tag 12,Tag Category 13,Tag 13,Tag Category 14,Tag 14,Tag Category 15,Tag 15,Tag Category 16,Tag 16,Tag Category 17,Tag 17,Tag Category 18,Tag 18,Tag Category 19,Tag 19,Tag Category 20,Tag 20 -1,Customers,Legacy Customers management service,,Retail,,,corp.acme.demo,customers-tomcat,0.0.1-SNAPSHOT,war,git,https://git-acme.local/customers.git,,,Operating System,RHEL 8,Database,Oracle,Language,Java,Runtime,Tomcat,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, -1,Inventory,Inventory service,,Retail,,,corp.acme.demo,inventory,0.1.1-SNAPSHOT,war,git,https://git-acme.local/inventory.git,,,Operating System,RHEL 8,Database,Postgresql,Language,Java,Runtime,Quarkus,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, -1,Gateway,API Gateway,,Retail,,,corp.acme.demo,gateway,0.1.1-SNAPSHOT,war,git,https://git-acme.local/gateway.git,,,Operating System,RHEL 8,,,Language,Java,Runtime,Spring Boot,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Record Type 1,Application Name,Description,Comments,Business Service,Dependency,Dependency Direction,Binary Group,Binary Artifact,Binary Version,Binary Packaging,Repository Type,Repository URL,Repository Branch,Repository Path,Owner,Contributors,Tag Category 1,Tag 1,Tag Category 2,Tag 2,Tag Category 3,Tag 3,Tag Category 4,Tag 4,Tag Category 5,Tag 5,Tag Category 6,Tag 6,Tag Category 7,Tag 7,Tag Category 8,Tag 8,Tag Category 9,Tag 9,Tag Category 10,Tag 10,Tag Category 11,Tag 11,Tag Category 12,Tag 12,Tag Category 13,Tag 13,Tag Category 14,Tag 14,Tag Category 15,Tag 15,Tag Category 16,Tag 16,Tag Category 17,Tag 17,Tag Category 18,Tag 18,Tag Category 19,Tag 19,Tag Category 20,Tag 20 +1,Customers,Legacy Customers management service,,Retail,,,corp.acme.demo,customers-tomcat,0.0.1-SNAPSHOT,war,git,https://git-acme.local/customers.git,,,John Doe ,,Operating System,RHEL 8,Database,Oracle,Language,Java,Runtime,Tomcat,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +1,Inventory,Inventory service,,Retail,,,corp.acme.demo,inventory,0.1.1-SNAPSHOT,war,git,https://git-acme.local/inventory.git,,,,"John Doe , Jane Smith ",Operating System,RHEL 8,Database,Postgresql,Language,Java,Runtime,Quarkus,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +1,Gateway,API Gateway,,Retail,,,corp.acme.demo,gateway,0.1.1-SNAPSHOT,war,git,https://git-acme.local/gateway.git,,,John Doe ,"John Doe , Jane Smith ",Operating System,RHEL 8,,,Language,Java,Runtime,Spring Boot,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 2,Gateway,,,,Inventory,southbound 2,Gateway,,,,Customers,southbound