remove auto-generated ruby tests (#17402)

This commit is contained in:
William Cheng 2023-12-15 14:47:15 +08:00 committed by GitHub
parent e63563a8fc
commit 809d7151c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 0 additions and 386 deletions

View File

@ -301,10 +301,6 @@ public class RubyClientCodegen extends AbstractRubyCodegen {
.doNotOverwrite());
supportingFiles.add(new SupportingFile("spec_helper.mustache", specFolder, "spec_helper.rb")
.doNotOverwrite());
supportingFiles.add(new SupportingFile("configuration_spec.mustache", specFolder, "configuration_spec.rb")
.doNotOverwrite());
supportingFiles.add(new SupportingFile("api_client_spec.mustache", specFolder, "api_client_spec.rb")
.doNotOverwrite());
// add lambda to convert a symbol to a string if an underscore is included (e.g. :'user_uuid' => 'user_uuid')
additionalProperties.put("lambdaFixHeaderKey", new Mustache.Lambda() {

View File

@ -1,257 +0,0 @@
=begin
{{> api_info}}
=end
require 'spec_helper'
describe {{moduleName}}::ApiClient do
context 'initialization' do
context 'URL stuff' do
context 'host' do
it 'removes http from host' do
{{moduleName}}.configure { |c| c.host = 'http://example.com' }
expect({{moduleName}}::Configuration.default.host).to eq('example.com')
end
it 'removes https from host' do
{{moduleName}}.configure { |c| c.host = 'https://wookiee.com' }
expect({{moduleName}}::ApiClient.default.config.host).to eq('wookiee.com')
end
it 'removes trailing path from host' do
{{moduleName}}.configure { |c| c.host = 'hobo.com/v4' }
expect({{moduleName}}::Configuration.default.host).to eq('hobo.com')
end
end
context 'base_path' do
it "prepends a slash to base_path" do
{{moduleName}}.configure { |c| c.base_path = 'v4/dog' }
expect({{moduleName}}::Configuration.default.base_path).to eq('/v4/dog')
end
it "doesn't prepend a slash if one is already there" do
{{moduleName}}.configure { |c| c.base_path = '/v4/dog' }
expect({{moduleName}}::Configuration.default.base_path).to eq('/v4/dog')
end
it "ends up as a blank string if nil" do
{{moduleName}}.configure { |c| c.base_path = nil }
expect({{moduleName}}::Configuration.default.base_path).to eq('')
end
end
end
end
{{#isTyphoeus}}
describe 'params_encoding in #build_request' do
let(:config) { {{moduleName}}::Configuration.new }
let(:api_client) { {{moduleName}}::ApiClient.new(config) }
it 'defaults to nil' do
expect({{moduleName}}::Configuration.default.params_encoding).to eq(nil)
expect(config.params_encoding).to eq(nil)
request = api_client.build_request(:get, '/test')
expect(request.options[:params_encoding]).to eq(nil)
end
it 'can be customized' do
config.params_encoding = :multi
request = api_client.build_request(:get, '/test')
expect(request.options[:params_encoding]).to eq(:multi)
end
end
describe 'timeout in #build_request' do
let(:config) { {{moduleName}}::Configuration.new }
let(:api_client) { {{moduleName}}::ApiClient.new(config) }
it 'defaults to 0' do
expect({{moduleName}}::Configuration.default.timeout).to eq(0)
expect(config.timeout).to eq(0)
request = api_client.build_request(:get, '/test')
expect(request.options[:timeout]).to eq(0)
end
it 'can be customized' do
config.timeout = 100
request = api_client.build_request(:get, '/test')
expect(request.options[:timeout]).to eq(100)
end
end
{{/isTyphoeus}}
{{#isFaraday}}
describe 'proxy in #build_connection' do
let(:config) { {{moduleName}}::Configuration.new }
let(:api_client) { {{moduleName}}::ApiClient.new(config) }
let(:proxy_uri) { URI('http://example.org:8080') }
it 'defaults to nil' do
expect({{moduleName}}::Configuration.default.proxy).to be_nil
expect(config.proxy).to be_nil
connection = api_client.build_connection
expect(connection.proxy_for_request('/test')).to be_nil
end
it 'can be customized with a string' do
config.proxy = proxy_uri.to_s
connection = api_client.build_connection
configured_proxy = connection.proxy_for_request('/test')
expect(configured_proxy).not_to be_nil
expect(configured_proxy.uri.to_s).to eq proxy_uri.to_s
end
it 'can be customized with a hash' do
config.proxy = { uri: proxy_uri }
connection = api_client.build_connection
configured_proxy = connection.proxy_for_request('/test')
expect(configured_proxy).not_to be_nil
expect(configured_proxy.uri).to eq proxy_uri
end
end
{{/isFaraday}}
describe '#deserialize' do
it "handles Array<Integer>" do
api_client = {{moduleName}}::ApiClient.new
headers = { 'Content-Type' => 'application/json' }
response = double('response', headers: headers, body: '[12, 34]')
data = api_client.deserialize(response, 'Array<Integer>')
expect(data).to be_instance_of(Array)
expect(data).to eq([12, 34])
end
it 'handles Array<Array<Integer>>' do
api_client = {{moduleName}}::ApiClient.new
headers = { 'Content-Type' => 'application/json' }
response = double('response', headers: headers, body: '[[12, 34], [56]]')
data = api_client.deserialize(response, 'Array<Array<Integer>>')
expect(data).to be_instance_of(Array)
expect(data).to eq([[12, 34], [56]])
end
it 'handles Hash<String, String>' do
api_client = {{moduleName}}::ApiClient.new
headers = { 'Content-Type' => 'application/json' }
response = double('response', headers: headers, body: '{"message": "Hello"}')
data = api_client.deserialize(response, 'Hash<String, String>')
expect(data).to be_instance_of(Hash)
expect(data).to eq(:message => 'Hello')
end
end
describe "#object_to_hash" do
it 'ignores nils and includes empty arrays' do
# uncomment below to test object_to_hash for model
# api_client = {{moduleName}}::ApiClient.new
# _model = {{moduleName}}::ModelName.new
# update the model attribute below
# _model.id = 1
# update the expected value (hash) below
# expected = {id: 1, name: '', tags: []}
# expect(api_client.object_to_hash(_model)).to eq(expected)
end
end
describe '#build_collection_param' do
let(:param) { ['aa', 'bb', 'cc'] }
let(:api_client) { {{moduleName}}::ApiClient.new }
it 'works for csv' do
expect(api_client.build_collection_param(param, :csv)).to eq('aa,bb,cc')
end
it 'works for ssv' do
expect(api_client.build_collection_param(param, :ssv)).to eq('aa bb cc')
end
it 'works for tsv' do
expect(api_client.build_collection_param(param, :tsv)).to eq("aa\tbb\tcc")
end
it 'works for pipes' do
expect(api_client.build_collection_param(param, :pipes)).to eq('aa|bb|cc')
end
it 'works for multi' do
expect(api_client.build_collection_param(param, :multi)).to eq(['aa', 'bb', 'cc'])
end
it 'fails for invalid collection format' do
expect { api_client.build_collection_param(param, :INVALID) }.to raise_error(RuntimeError, 'unknown collection format: :INVALID')
end
end
describe '#json_mime?' do
let(:api_client) { {{moduleName}}::ApiClient.new }
it 'works' do
expect(api_client.json_mime?(nil)).to eq false
expect(api_client.json_mime?('')).to eq false
expect(api_client.json_mime?('application/json')).to eq true
expect(api_client.json_mime?('application/json; charset=UTF8')).to eq true
expect(api_client.json_mime?('APPLICATION/JSON')).to eq true
expect(api_client.json_mime?('application/xml')).to eq false
expect(api_client.json_mime?('text/plain')).to eq false
expect(api_client.json_mime?('application/jsonp')).to eq false
end
end
describe '#select_header_accept' do
let(:api_client) { {{moduleName}}::ApiClient.new }
it 'works' do
expect(api_client.select_header_accept(nil)).to be_nil
expect(api_client.select_header_accept([])).to be_nil
expect(api_client.select_header_accept(['application/json'])).to eq('application/json')
expect(api_client.select_header_accept(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
expect(api_client.select_header_accept(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
expect(api_client.select_header_accept(['application/xml'])).to eq('application/xml')
expect(api_client.select_header_accept(['text/html', 'application/xml'])).to eq('text/html,application/xml')
end
end
describe '#select_header_content_type' do
let(:api_client) { {{moduleName}}::ApiClient.new }
it 'works' do
expect(api_client.select_header_content_type(nil)).to be_nil
expect(api_client.select_header_content_type([])).to be_nil
expect(api_client.select_header_content_type(['application/json'])).to eq('application/json')
expect(api_client.select_header_content_type(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
expect(api_client.select_header_content_type(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
expect(api_client.select_header_content_type(['application/xml'])).to eq('application/xml')
expect(api_client.select_header_content_type(['text/plain', 'application/xml'])).to eq('text/plain')
end
end
describe '#sanitize_filename' do
let(:api_client) { {{moduleName}}::ApiClient.new }
it 'works' do
expect(api_client.sanitize_filename('sun')).to eq('sun')
expect(api_client.sanitize_filename('sun.gif')).to eq('sun.gif')
expect(api_client.sanitize_filename('../sun.gif')).to eq('sun.gif')
expect(api_client.sanitize_filename('/var/tmp/sun.gif')).to eq('sun.gif')
expect(api_client.sanitize_filename('./sun.gif')).to eq('sun.gif')
expect(api_client.sanitize_filename('..\sun.gif')).to eq('sun.gif')
expect(api_client.sanitize_filename('\var\tmp\sun.gif')).to eq('sun.gif')
expect(api_client.sanitize_filename('c:\var\tmp\sun.gif')).to eq('sun.gif')
expect(api_client.sanitize_filename('.\sun.gif')).to eq('sun.gif')
end
end
end

View File

@ -1,111 +0,0 @@
=begin
{{> api_info}}
=end
require 'spec_helper'
describe {{moduleName}}::Configuration do
let(:config) { {{moduleName}}::Configuration.default }
before(:each) do
# uncomment below to setup host and base_path
# require 'URI'
# uri = URI.parse("{{{basePath}}}")
# {{moduleName}}.configure do |c|
# c.host = uri.host
# c.base_path = uri.path
# end
end
describe '#base_url' do
it 'should have the default value' do
# uncomment below to test default value of the base path
# expect(config.base_url).to eq("{{{basePath}}}")
end
it 'should remove trailing slashes' do
[nil, '', '/', '//'].each do |base_path|
config.base_path = base_path
# uncomment below to test trailing slashes
# expect(config.base_url).to eq("{{{basePath}}}")
end
end
end
{{#isFaraday}}
describe '#configure_faraday_connection' do
let(:faraday_connection) { Faraday::Connection.new }
before do
stub_const('CustomAdapter', Class.new(Faraday::Adapter))
stub_const('AnotherCustomAdapter', Class.new(Faraday::Adapter))
config.configure_faraday_connection do |conn|
conn.adapter CustomAdapter
conn.response :logger, nil, headers: true, bodies: true, log_level: :debug do |logger|
logger.filter(/(Authorization: )(.*)/, '\1[REDACTED]')
end
end
end
it 'adds a block that will be used to configure the connection' do
expect(faraday_connection.adapter).to eq(Faraday::Adapter::NetHttp)
expect(faraday_connection.builder.handlers).to_not include(Faraday::Response::Logger)
config.configure_connection(faraday_connection)
expect(faraday_connection.adapter).to eq(CustomAdapter)
expect(faraday_connection.builder.handlers).to include(Faraday::Response::Logger)
end
it 'supports multiple configuration blocks' do
config.configure_faraday_connection do |conn|
conn.adapter AnotherCustomAdapter
end
expect(faraday_connection.adapter).to eq(Faraday::Adapter::NetHttp)
expect(faraday_connection.builder.handlers).to_not include(Faraday::Response::Logger)
config.configure_connection(faraday_connection)
expect(faraday_connection.adapter).to eq(AnotherCustomAdapter)
expect(faraday_connection.builder.handlers).to include(Faraday::Response::Logger)
end
end
{{/isFaraday}}
{{#isHttpx}}
describe '#configure' do
let(:session) { HTTPX::Session.new }
before do
module CustomPlugin
module InstanceMethods; end
end
module AnotherCustomPlugin
module InstanceMethods; end
end
config.configure_session do |session|
session.plugin(CustomPlugin)
end
end
it 'adds a block that will be used to configure the connection' do
sess = config.configure(session)
expect(sess.class.ancestors).to include(CustomPlugin::InstanceMethods)
end
it 'supports multiple configuration blocks' do
config.configure_session do |session|
session.plugin(AnotherCustomPlugin)
end
sess = config.configure(session)
expect(sess.class.ancestors).to include(CustomPlugin::InstanceMethods)
expect(sess.class.ancestors).to include(AnotherCustomPlugin::InstanceMethods)
end
end
{{/isHttpx}}
end

View File

@ -127,6 +127,4 @@ lib/petstore/models/test_inline_freeform_additional_properties_request.rb
lib/petstore/models/user.rb
lib/petstore/version.rb
petstore.gemspec
spec/api_client_spec.rb
spec/configuration_spec.rb
spec/spec_helper.rb

View File

@ -127,6 +127,4 @@ lib/petstore/models/test_inline_freeform_additional_properties_request.rb
lib/petstore/models/user.rb
lib/petstore/version.rb
petstore.gemspec
spec/api_client_spec.rb
spec/configuration_spec.rb
spec/spec_helper.rb

View File

@ -135,6 +135,4 @@ lib/petstore/models/whale.rb
lib/petstore/models/zebra.rb
lib/petstore/version.rb
petstore.gemspec
spec/api_client_spec.rb
spec/configuration_spec.rb
spec/spec_helper.rb

View File

@ -135,6 +135,4 @@ lib/petstore/models/whale.rb
lib/petstore/models/zebra.rb
lib/petstore/version.rb
petstore.gemspec
spec/api_client_spec.rb
spec/configuration_spec.rb
spec/spec_helper.rb

View File

@ -14,7 +14,5 @@ lib/x_auth_id_alias/api_client.rb
lib/x_auth_id_alias/api_error.rb
lib/x_auth_id_alias/configuration.rb
lib/x_auth_id_alias/version.rb
spec/api_client_spec.rb
spec/configuration_spec.rb
spec/spec_helper.rb
x_auth_id_alias.gemspec

View File

@ -15,6 +15,4 @@ lib/dynamic_servers/api_client.rb
lib/dynamic_servers/api_error.rb
lib/dynamic_servers/configuration.rb
lib/dynamic_servers/version.rb
spec/api_client_spec.rb
spec/configuration_spec.rb
spec/spec_helper.rb

View File

@ -19,6 +19,4 @@ lib/petstore/models/array_alias.rb
lib/petstore/models/map_alias.rb
lib/petstore/version.rb
petstore.gemspec
spec/api_client_spec.rb
spec/configuration_spec.rb
spec/spec_helper.rb