|
| 1 | +package google |
| 2 | + |
| 3 | +import ( |
| 4 | + "net/http/httptest" |
| 5 | + "strings" |
| 6 | +) |
| 7 | + |
| 8 | +// NewTestConfig create a config using the http test server. |
| 9 | +func NewTestConfig(server *httptest.Server) *Config { |
| 10 | + cfg := &Config{} |
| 11 | + cfg.client = server.Client() |
| 12 | + configureTestBasePaths(cfg, server.URL) |
| 13 | + return cfg |
| 14 | +} |
| 15 | + |
| 16 | +func configureTestBasePaths(c *Config, url string) { |
| 17 | + if !strings.HasSuffix(url, "/") { |
| 18 | + url = url + "/" |
| 19 | + } |
| 20 | + // Generated Products |
| 21 | + c.AccessApprovalBasePath = url |
| 22 | + c.AccessContextManagerBasePath = url |
| 23 | + c.ActiveDirectoryBasePath = url |
| 24 | + c.ApigeeBasePath = url |
| 25 | + c.AppEngineBasePath = url |
| 26 | + c.ArtifactRegistryBasePath = url |
| 27 | + c.BeyondcorpBasePath = url |
| 28 | + c.BigQueryBasePath = url |
| 29 | + c.BigqueryAnalyticsHubBasePath = url |
| 30 | + c.BigqueryConnectionBasePath = url |
| 31 | + c.BigqueryDataTransferBasePath = url |
| 32 | + c.BigqueryReservationBasePath = url |
| 33 | + c.BigtableBasePath = url |
| 34 | + c.BillingBasePath = url |
| 35 | + c.BinaryAuthorizationBasePath = url |
| 36 | + c.CertificateManagerBasePath = url |
| 37 | + c.CloudAssetBasePath = url |
| 38 | + c.CloudBuildBasePath = url |
| 39 | + c.CloudFunctionsBasePath = url |
| 40 | + c.Cloudfunctions2BasePath = url |
| 41 | + c.CloudIdentityBasePath = url |
| 42 | + c.CloudIdsBasePath = url |
| 43 | + c.CloudIotBasePath = url |
| 44 | + c.CloudRunBasePath = url |
| 45 | + c.CloudSchedulerBasePath = url |
| 46 | + c.CloudTasksBasePath = url |
| 47 | + c.ComputeBasePath = url |
| 48 | + c.ContainerAnalysisBasePath = url |
| 49 | + c.DataCatalogBasePath = url |
| 50 | + c.DataFusionBasePath = url |
| 51 | + c.DataLossPreventionBasePath = url |
| 52 | + c.DataprocBasePath = url |
| 53 | + c.DataprocMetastoreBasePath = url |
| 54 | + c.DatastoreBasePath = url |
| 55 | + c.DatastreamBasePath = url |
| 56 | + c.DeploymentManagerBasePath = url |
| 57 | + c.DialogflowBasePath = url |
| 58 | + c.DialogflowCXBasePath = url |
| 59 | + c.DNSBasePath = url |
| 60 | + c.DocumentAIBasePath = url |
| 61 | + c.EssentialContactsBasePath = url |
| 62 | + c.FilestoreBasePath = url |
| 63 | + c.FirestoreBasePath = url |
| 64 | + c.GameServicesBasePath = url |
| 65 | + c.GKEHubBasePath = url |
| 66 | + c.HealthcareBasePath = url |
| 67 | + c.IAMBetaBasePath = url |
| 68 | + c.IapBasePath = url |
| 69 | + c.IdentityPlatformBasePath = url |
| 70 | + c.KMSBasePath = url |
| 71 | + c.LoggingBasePath = url |
| 72 | + c.MemcacheBasePath = url |
| 73 | + c.MLEngineBasePath = url |
| 74 | + c.MonitoringBasePath = url |
| 75 | + c.NetworkManagementBasePath = url |
| 76 | + c.NetworkServicesBasePath = url |
| 77 | + c.NotebooksBasePath = url |
| 78 | + c.OSConfigBasePath = url |
| 79 | + c.OSLoginBasePath = url |
| 80 | + c.PrivatecaBasePath = url |
| 81 | + c.PubsubBasePath = url |
| 82 | + c.PubsubLiteBasePath = url |
| 83 | + c.RedisBasePath = url |
| 84 | + c.ResourceManagerBasePath = url |
| 85 | + c.SecretManagerBasePath = url |
| 86 | + c.SecurityCenterBasePath = url |
| 87 | + c.ServiceManagementBasePath = url |
| 88 | + c.ServiceUsageBasePath = url |
| 89 | + c.SourceRepoBasePath = url |
| 90 | + c.SpannerBasePath = url |
| 91 | + c.SQLBasePath = url |
| 92 | + c.StorageBasePath = url |
| 93 | + c.StorageTransferBasePath = url |
| 94 | + c.TagsBasePath = url |
| 95 | + c.TPUBasePath = url |
| 96 | + c.VertexAIBasePath = url |
| 97 | + c.VPCAccessBasePath = url |
| 98 | + c.WorkflowsBasePath = url |
| 99 | + |
| 100 | + // Handwritten Products / Versioned / Atypical Entries |
| 101 | + c.CloudBillingBasePath = url |
| 102 | + c.ComposerBasePath = url |
| 103 | + c.ContainerBasePath = url |
| 104 | + c.DataprocBasePath = url |
| 105 | + c.DataflowBasePath = url |
| 106 | + c.IamCredentialsBasePath = url |
| 107 | + c.ResourceManagerV3BasePath = url |
| 108 | + c.IAMBasePath = url |
| 109 | + c.ServiceNetworkingBasePath = url |
| 110 | + c.BigQueryBasePath = url |
| 111 | + c.StorageTransferBasePath = url |
| 112 | + c.BigtableAdminBasePath = url |
| 113 | +} |
0 commit comments