Skip to content

Commit

Permalink
fix: Fix wrapper tests with universe domain changes (#1031)
Browse files Browse the repository at this point in the history
  • Loading branch information
dazuma authored Jan 12, 2024
1 parent 90941ff commit 6acc014
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 10 deletions.
14 changes: 12 additions & 2 deletions gapic-generator-cloud/templates/cloud/wrapper_gem/client_test.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,21 @@ require "gapic/rest"
<%- end -%>

class <%= gem.namespace %>::ClientConstructionMinitest < Minitest::Test
class DummyStub
def endpoint
"endpoint.example.com"
end

def universe_domain
"example.com"
end
end

<%- start_line_spacer -%>
<%- gem.services.each do |service| -%>
<%- if service.generate_grpc_clients? -%>
<%= line_spacer %> def test_<%= service.factory_method_name %>_grpc
Gapic::ServiceStub.stub :new, :stub do
Gapic::ServiceStub.stub :new, DummyStub.new do
grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure
client = <%= gem.namespace %>.<%= service.factory_method_name %><% if service.supports_multiple_transports? %> transport: :grpc<% end %> do |config|
config.credentials = grpc_channel
Expand All @@ -27,7 +37,7 @@ class <%= gem.namespace %>::ClientConstructionMinitest < Minitest::Test
<%- end -%>
<%- if service.generate_rest_clients? -%>
<%= line_spacer %> def test_<%= service.factory_method_name %>_rest
Gapic::Rest::ClientStub.stub :new, :stub do
Gapic::Rest::ClientStub.stub :new, DummyStub.new do
client = <%= gem.namespace %>.<%= service.factory_method_name %><% if service.supports_multiple_transports? %> transport: :rest<% end %> do |config|
config.credentials = :dummy_credentials
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,18 @@
require "gapic/rest"

class Google::Cloud::Compute::ClientConstructionMinitest < Minitest::Test
class DummyStub
def endpoint
"endpoint.example.com"
end

def universe_domain
"example.com"
end
end

def test_addresses_rest
Gapic::Rest::ClientStub.stub :new, :stub do
Gapic::Rest::ClientStub.stub :new, DummyStub.new do
client = Google::Cloud::Compute.addresses do |config|
config.credentials = :dummy_credentials
end
Expand All @@ -32,7 +42,7 @@ def test_addresses_rest
end

def test_region_operations_rest
Gapic::Rest::ClientStub.stub :new, :stub do
Gapic::Rest::ClientStub.stub :new, DummyStub.new do
client = Google::Cloud::Compute.region_operations do |config|
config.credentials = :dummy_credentials
end
Expand All @@ -41,7 +51,7 @@ def test_region_operations_rest
end

def test_region_instance_group_managers_rest
Gapic::Rest::ClientStub.stub :new, :stub do
Gapic::Rest::ClientStub.stub :new, DummyStub.new do
client = Google::Cloud::Compute.region_instance_group_managers do |config|
config.credentials = :dummy_credentials
end
Expand All @@ -50,7 +60,7 @@ def test_region_instance_group_managers_rest
end

def test_networks_rest
Gapic::Rest::ClientStub.stub :new, :stub do
Gapic::Rest::ClientStub.stub :new, DummyStub.new do
client = Google::Cloud::Compute.networks do |config|
config.credentials = :dummy_credentials
end
Expand All @@ -59,7 +69,7 @@ def test_networks_rest
end

def test_global_operations_rest
Gapic::Rest::ClientStub.stub :new, :stub do
Gapic::Rest::ClientStub.stub :new, DummyStub.new do
client = Google::Cloud::Compute.global_operations do |config|
config.credentials = :dummy_credentials
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,18 @@
require "gapic/rest"

class Google::Cloud::Language::ClientConstructionMinitest < Minitest::Test
class DummyStub
def endpoint
"endpoint.example.com"
end

def universe_domain
"example.com"
end
end

def test_language_service_grpc
Gapic::ServiceStub.stub :new, :stub do
Gapic::ServiceStub.stub :new, DummyStub.new do
grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure
client = Google::Cloud::Language.language_service transport: :grpc do |config|
config.credentials = grpc_channel
Expand All @@ -34,7 +44,7 @@ def test_language_service_grpc
end

def test_language_service_rest
Gapic::Rest::ClientStub.stub :new, :stub do
Gapic::Rest::ClientStub.stub :new, DummyStub.new do
client = Google::Cloud::Language.language_service transport: :rest do |config|
config.credentials = :dummy_credentials
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,18 @@
require "gapic/grpc"

class Google::Cloud::SecretManager::ClientConstructionMinitest < Minitest::Test
class DummyStub
def endpoint
"endpoint.example.com"
end

def universe_domain
"example.com"
end
end

def test_secret_manager_service_grpc
Gapic::ServiceStub.stub :new, :stub do
Gapic::ServiceStub.stub :new, DummyStub.new do
grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure
client = Google::Cloud::SecretManager.secret_manager_service do |config|
config.credentials = grpc_channel
Expand Down

0 comments on commit 6acc014

Please sign in to comment.