github.com/kyma-incubator/compass/components/director@v0.0.0-20230623144113-d764f56ff805/internal/domain/ordvendor/fixtures_test.go (about) 1 package ordvendor_test 2 3 import ( 4 "database/sql/driver" 5 "encoding/json" 6 7 "github.com/kyma-incubator/compass/components/director/pkg/str" 8 9 "github.com/kyma-incubator/compass/components/director/internal/repo" 10 11 "github.com/kyma-incubator/compass/components/director/internal/domain/ordvendor" 12 "github.com/kyma-incubator/compass/components/director/internal/model" 13 ) 14 15 const ( 16 vendorID = "vendorID" 17 tenantID = "b91b59f7-2563-40b2-aba9-fef726037aa3" 18 appID = "appID" 19 appTemplateVersionID = "appTemplateVersionID" 20 ordID = "com.compass.v1" 21 externalTenantID = "externalTenantID" 22 partners = `["microsoft:vendor:Microsoft:"]` 23 ) 24 25 func fixEntityVendor() *ordvendor.Entity { 26 return &ordvendor.Entity{ 27 ID: vendorID, 28 OrdID: ordID, 29 ApplicationID: repo.NewValidNullableString(appID), 30 Title: "title", 31 Partners: repo.NewValidNullableString(partners), 32 Tags: repo.NewValidNullableString("[]"), 33 Labels: repo.NewValidNullableString("{}"), 34 DocumentationLabels: repo.NewValidNullableString("[]"), 35 } 36 } 37 38 func fixEntityVendorWithTitle(title string) *ordvendor.Entity { 39 return &ordvendor.Entity{ 40 ID: vendorID, 41 OrdID: ordID, 42 Title: title, 43 Partners: repo.NewValidNullableString(partners), 44 Tags: repo.NewValidNullableString("[]"), 45 Labels: repo.NewValidNullableString("{}"), 46 DocumentationLabels: repo.NewValidNullableString("[]"), 47 } 48 } 49 50 func fixEntityVendorWithTitleForApp(title string) *ordvendor.Entity { 51 entity := fixEntityVendorWithTitle(title) 52 entity.ApplicationID = repo.NewValidNullableString(appID) 53 return entity 54 } 55 56 func fixEntityVendorWithTitleForAppTemplateVersion(title string) *ordvendor.Entity { 57 entity := fixEntityVendorWithTitle(title) 58 entity.ApplicationTemplateVersionID = repo.NewValidNullableString(appTemplateVersionID) 59 return entity 60 } 61 62 func fixVendorModelWithTitle(title string) *model.Vendor { 63 return &model.Vendor{ 64 ID: vendorID, 65 OrdID: ordID, 66 Title: title, 67 Partners: json.RawMessage(partners), 68 Tags: json.RawMessage("[]"), 69 Labels: json.RawMessage("{}"), 70 DocumentationLabels: json.RawMessage("[]"), 71 } 72 } 73 74 func fixVendorModelWithTitleForAppTemplateVersion(title string) *model.Vendor { 75 vendor := fixVendorModelWithTitle(title) 76 vendor.ApplicationTemplateVersionID = str.Ptr(appTemplateVersionID) 77 return vendor 78 } 79 80 func fixVendorModelWithTitleForApp(title string) *model.Vendor { 81 vendor := fixVendorModelWithTitle(title) 82 vendor.ApplicationID = str.Ptr(appID) 83 return vendor 84 } 85 86 func fixVendorModel() *model.Vendor { 87 return &model.Vendor{ 88 ID: vendorID, 89 OrdID: ordID, 90 Title: "title", 91 Partners: json.RawMessage(partners), 92 Tags: json.RawMessage("[]"), 93 Labels: json.RawMessage("{}"), 94 DocumentationLabels: json.RawMessage("[]"), 95 } 96 } 97 98 func fixVendorModelForApp() *model.Vendor { 99 vendor := fixVendorModel() 100 vendor.ApplicationID = str.Ptr(appID) 101 return vendor 102 } 103 104 func fixVendorModelForAppTemplateVersion() *model.Vendor { 105 vendor := fixVendorModel() 106 vendor.ApplicationTemplateVersionID = str.Ptr(appTemplateVersionID) 107 return vendor 108 } 109 110 func fixGlobalVendorModel() *model.Vendor { 111 return &model.Vendor{ 112 ID: vendorID, 113 OrdID: ordID, 114 Title: "title", 115 Partners: json.RawMessage(partners), 116 Tags: json.RawMessage("[]"), 117 Labels: json.RawMessage("{}"), 118 DocumentationLabels: json.RawMessage("[]"), 119 } 120 } 121 122 func fixNilModelVendor() *model.Vendor { 123 return nil 124 } 125 126 func fixVendorModelInput() *model.VendorInput { 127 return &model.VendorInput{ 128 OrdID: ordID, 129 Title: "title", 130 Partners: json.RawMessage(partners), 131 Tags: json.RawMessage("[]"), 132 Labels: json.RawMessage("{}"), 133 DocumentationLabels: json.RawMessage("[]"), 134 } 135 } 136 137 func fixVendorColumns() []string { 138 return []string{"ord_id", "app_id", "app_template_version_id", "title", "labels", "partners", "id", "tags", "documentation_labels"} 139 } 140 141 func fixVendorRow() []driver.Value { 142 return []driver.Value{ordID, appID, repo.NewValidNullableString(""), "title", repo.NewValidNullableString("{}"), repo.NewValidNullableString(partners), vendorID, repo.NewValidNullableString("[]"), repo.NewValidNullableString("[]")} 143 } 144 145 func fixVendorRowWithTitleForApp(title string) []driver.Value { 146 return []driver.Value{ordID, appID, repo.NewValidNullableString(""), title, repo.NewValidNullableString("{}"), repo.NewValidNullableString(partners), vendorID, repo.NewValidNullableString("[]"), repo.NewValidNullableString("[]")} 147 } 148 149 func fixVendorRowWithTitleForAppTemplateVersion(title string) []driver.Value { 150 return []driver.Value{ordID, repo.NewValidNullableString(""), appTemplateVersionID, title, repo.NewValidNullableString("{}"), repo.NewValidNullableString(partners), vendorID, repo.NewValidNullableString("[]"), repo.NewValidNullableString("[]")} 151 } 152 153 func fixVendorUpdateArgs() []driver.Value { 154 return []driver.Value{"title", repo.NewValidNullableString("{}"), repo.NewValidNullableString(partners), repo.NewValidNullableString("[]"), repo.NewValidNullableString("[]")} 155 }