зеркало из
1
0
Форкнуть 0
This commit is contained in:
Veronica Giaudrone 2017-09-14 14:32:05 -07:00
Родитель 3bc168dd4a
Коммит 554c30e734
58 изменённых файлов: 498 добавлений и 498 удалений

Просмотреть файл

@ -0,0 +1,58 @@
# # encoding: utf-8
# # Copyright (c) Microsoft Corporation. All rights reserved.
# # Licensed under the MIT License. See License.txt in the project root for license information.
#
# require_relative 'spec_helper'
#
# include MsRestAzure
# include Azure::ARM::Resources
#
# describe 'Deployment Operations' do
# before(:each) do
# @resource_helper = ResourceHelper.new()
# @client = @resource_helper.resource_client.deployment_operations
# @resource_group = @resource_helper.create_resource_group
# @deployment = @resource_helper.create_deployment(@resource_group.name)
# @resource_helper.wait_for_deployment(@resource_group.name, @deployment.name, @resource_helper.build_deployment_params)
# end
#
# after(:each) do
# @resource_helper.delete_resource_group(@resource_group.name)
# end
#
# it 'should get a list of deployment operations' do
# result = @client.list_async(@resource_group.name, @deployment.name).value!
# expect(result.response.status).to eq(200)
# expect(result.body).not_to be_nil
# expect(result.body.value).to be_a(Array)
#
# while !result.body.next_link.nil? && !result.body.next_link.empty? do
# result = @client.list_next(result.body.next_link).value!
# expect(result.body.value).not_to be_nil
# expect(result.body.value).to be_a(Array)
# end
# end
#
# it 'should get a list of deployment operation restricted with top parameter' do
# result = @client.list_async(@resource_group.name, @deployment.name, 1).value!
# expect(result.response.status).to eq(200)
# expect(result.body).not_to be_nil
# expect(result.body.value).to be_a(Array)
#
# while !result.body.next_link.nil? && !result.body.next_link.empty? do
# result = @client.list_next_async(result.body.next_link).value!
# expect(result.body.value).not_to be_nil
# expect(result.body.value).to be_a(Array)
# end
# end
#
# it 'should get a deployment operation' do
# operations = @client.list_async(@resource_group.name, @deployment.name).value!.body.value
#
# result = @client.get_async(@resource_group.name, @deployment.name, operations[0].operation_id).value!
# expect(result.response.status).to eq(200)
# expect(result.body.operation_id).to eq(operations[0].operation_id)
# expect(result.body.id).not_to be_nil
# expect(result.body.properties).to be_an_instance_of(Models::DeploymentOperationProperties)
# end
# end

Просмотреть файл

@ -0,0 +1,103 @@
# # encoding: utf-8
# # Copyright (c) Microsoft Corporation. All rights reserved.
# # Licensed under the MIT License. See License.txt in the project root for license information.
#
# require_relative 'spec_helper'
#
# include MsRestAzure
# include Azure::ARM::Resources
#
# describe 'Template Deployments' do
#
# before(:each) do
# @resource_helper = ResourceHelper.new()
# @client = @resource_helper.resource_client.deployments
# @resource_group = @resource_helper.create_resource_group
# end
#
# after(:each) do
# @resource_helper.delete_resource_group(@resource_group.name)
# end
#
# it 'should create template deployment' do
# deployment_name = 'Deployment_test'
# result = @client.create_or_update_async(@resource_group.name, deployment_name, @resource_helper.build_deployment_params).value!
#
# expect(result.body.id).not_to be_nil
# expect(result.body.name).to eq(deployment_name)
# end
#
# it 'should raise error when attempting to create with invalid parameters' do
# expect{@client.create_or_update(nil, 'bar', @resource_helper.build_deployment_params)}.to raise_error(ArgumentError)
# expect{@client.create_or_update('foo', nil, @resource_helper.build_deployment_params)}.to raise_error(ArgumentError)
# expect{@client.create_or_update('foo', 'bar', nil)}.to raise_error(ArgumentError)
# expect{@client.create_or_update('~`123', 'bar', @resource_helper.build_deployment_params).value!}.to raise_error(MsRestAzure::AzureOperationError)
# end
#
# it 'should cancel running template deployment' do
# deployment = @resource_helper.begin_create_deployment(@resource_group.name)
# result = @client.cancel_async(@resource_group.name, deployment.name).value!
#
# expect(result.body).to be_nil
# expect(result.response.status).to eq(204)
# end
#
# it 'should raise error when attempting cancel deployment with invalid parameters' do
# expect{@client.cancel(nil, 'bar')}.to raise_error(ArgumentError)
# expect{@client.cancel('foo', nil)}.to raise_error(ArgumentError)
# end
#
# it 'should get a deployment' do
# deployment = @resource_helper.create_deployment(@resource_group.name)
#
# result = @client.get_async(@resource_group.name, deployment.name).value!
#
# expect(result.body.name).to eq(deployment.name)
# end
#
# it 'should raise error when attempting to get deployment with using invalid parameters' do
# expect{@client.get(nil, 'bar')}.to raise_error(ArgumentError)
# expect{@client.get('foo', nil)}.to raise_error(ArgumentError)
# expect{@client.get('~`123', 'bar').value!}.to raise_error(MsRestAzure::AzureOperationError)
# end
#
# it 'should validate a deployment' do
# deployment = @resource_helper.create_deployment(@resource_group.name)
# @resource_helper.wait_for_deployment(@resource_group.name, deployment.name, @resource_helper.build_deployment_params)
#
# result = @client.validate_async(@resource_group.name, deployment.name, @resource_helper.build_deployment_params).value!
# expect(result.response.status).to eq(200)
# end
#
# it 'should raise error when attempting validate with invalid parameters' do
# expect{@client.validate(nil, 'bar', @resource_helper.build_deployment_params)}.to raise_error(ArgumentError)
# expect{@client.validate('foo', 'bar', nil)}.to raise_error(ArgumentError)
# expect(@client.validate_async('~`123', 'bar', @resource_helper.build_deployment_params).value!.response.status).to eq(400)
# end
#
# it 'should get a list of deployments' do
# result = @client.list_by_resource_group_async(@resource_group.name).value!
# expect(result.body.value).not_to be_nil
# expect(result.body.value).to be_a(Array)
#
# while !result.body.next_link.nil? && !result.body.next_link.empty? do
# result = @client.list_next(result.body.next_link).value!
# expect(result.body.value).not_to be_nil
# expect(result.body.value).to be_a(Array)
# end
# end
#
# it 'should list filtered results restricted with top parameter' do
# filter = "provisioningState eq 'Running'"
# result = @client.list_by_resource_group_async(@resource_group.name, filter, 1).value!
# expect(result.body.value).not_to be_nil
# expect(result.body.value).to be_a(Array)
#
# while !result.body.next_link.nil? && !result.body.next_link.empty?.empty? do
# result = @client.list_next(result.body.next_link).value!
# expect(result.body.value).not_to be_nil
# expect(result.body.value).to be_a(Array)
# end
# end
#
# end

Просмотреть файл

@ -0,0 +1,106 @@
# # encoding: utf-8
# # Copyright (c) Microsoft Corporation. All rights reserved.
# # Licensed under the MIT License. See License.txt in the project root for license information.
#
# require_relative 'spec_helper'
#
# include MsRestAzure
# include Azure::ARM::Resources
#
# describe 'Providers' do
#
# before(:each) do
# @registered_providers = []
# @unregistered_providers = []
# @resource_helper = ResourceHelper.new()
# @client = @resource_helper.resource_client.providers
# end
#
# after(:each) do
# @registered_providers.each do |namespace|
# begin
# @client.unregister(namespace).value!
# rescue Exception
# end
# end
#
# @unregistered_providers.each do |namespace|
# begin
# @client.register(namespace).value!
# rescue Exception
# end
# end
# end
#
# it 'should list providers' do
# result = @client.list_async().value!
# expect(result.body.value).not_to be_nil
# expect(result.body.value).to be_a(Array)
#
# while !result.body.next_link.nil? && !result.body.next_link.empty? do
# result = @client.list_next_async(result.body.next_link).value!
# expect(result.body.value).not_to be_nil
# expect(result.body.value).to be_a(Array)
# end
# end
#
# it 'should list providers with top restriction parameter' do
# result = @client.list_async(1).value!
# expect(result.body.value).not_to be_nil
# expect(result.body.value).to be_a(Array)
#
# while !result.body.next_link.nil? && !result.body.next_link.empty? do
# result = @client.list_next(result.body.next_link).value!
# expect(result.body.value).not_to be_nil
# expect(result.body.value).to be_a(Array)
# end
# end
#
# it 'should register provider' do
# providers = @client.list_async().value!.body.value
# targetProvider = providers.detect do |item|
# item.registration_state == 'NotRegistered' || item.registration_state == 'Unregistered'
# end
# @registered_providers.push(targetProvider.namespace)
#
# result = @client.register_async(targetProvider.namespace).value!
#
# expect(result.response.status).to eq(200)
# expect(result.body.namespace).to eq(targetProvider.namespace)
# expect(result.body.registration_state).not_to eq('NotRegistered')
# end
#
# it 'should raise an error when attempting register provider with nil parameter' do
# expect{@client.register(nil)}.to raise_error(ArgumentError)
# end
#
# it 'should unregister provider' do
# providers = @client.list_async().value!.body.value
# targetProvider = providers.detect {|item| item.registration_state == 'Registered' }
# @unregistered_providers.push(targetProvider.namespace)
#
# result = @client.unregister_async(targetProvider.namespace).value!
#
# expect(result.response.status).to eq(200)
# expect(result.body.namespace).to eq(targetProvider.namespace)
# expect(result.body.registration_state).not_to eq('Registered')
# end
#
# it 'should raise an error when attempting unregister provider with nil parameter' do
# expect{@client.unregister(nil)}.to raise_error(ArgumentError)
# end
#
# it 'should get provider' do
# providers = @client.list_async().value!.body.value
#
# result = @client.get_async(providers[0].namespace).value!
#
# expect(result.body).not_to be_nil
# expect(result.body.namespace).to eq(providers[0].namespace)
# end
#
# it 'should raise error when attempting get provider with nil parameter' do
# expect{@client.get(nil)}.to raise_error(ArgumentError)
# end
#
# end

Просмотреть файл

@ -0,0 +1,159 @@
# # encoding: utf-8
# # Copyright (c) Microsoft Corporation. All rights reserved.
# # Licensed under the MIT License. See License.txt in the project root for license information.
#
# require_relative 'spec_helper'
#
# include MsRestAzure
# include Azure::ARM::Resources
#
# describe 'Resource Groups' do
# before(:each) do
# @resource_helper = ResourceHelper.new()
# @client = @resource_helper.resource_client.resource_groups
# end
#
# it 'should create and delete resource group' do
# name = 'RubySDKTest_azure_mgmt_resources'
#
# params = Models::ResourceGroup.new
# params.location = 'westus'
# params.tags = { 'tag1' => 'val1', 'tag2' => 'val2' }
#
# result = @client.create_or_update_async(name, params).value!
#
# expect(result.body).not_to be_nil
# expect(result.body.id).not_to be_nil
# expect(result.body.name).to eq(name)
# expect(result.body.location).to eq('westus')
# expect(result.body.tags).not_to be_nil
# expect(result.body.tags['tag1']).to eq('val1')
# expect(result.body.tags['tag2']).to eq('val2')
#
# result = @client.delete_async(name).value!
# expect(result.body).to be_nil
# expect(result.response.status).to eq(200)
# end
#
# it 'should create resource group - using generic request' do
# resource_client = @resource_helper.resource_client
# name = 'RubySDKTest_azure_mgmt_resources'
#
# request_content = "{'location':'westus','tags':{'tag1':'val1','tag2':'val2'}}"
# subscription_id = ENV['AZURE_SUBSCRIPTION_ID']
#
# path = "/subscriptions/#{subscription_id}/resourcegroups/#{name}?api-version=2016-09-01"
#
# options = {
# body: request_content
# }
#
# result = resource_client.make_request(:put, path, options)
#
# expect(result['id']).not_to be_nil
# expect(result['name']).to eq(name)
# expect(result['location']).to eq('westus')
# expect(result['tags']).not_to be_nil
# expect(result['tags']['tag1']).to eq('val1')
# expect(result['tags']['tag2']).to eq('val2')
# end
#
# it 'should throw exception when create or update with nil parameters' do
# params = Models::ResourceGroup.new
# expect{@client.create_or_update_async(nil, params)}.to raise_error(ArgumentError)
# expect{@client.create_or_update_async('foo', nil)}.to raise_error(ArgumentError)
# end
#
# it 'should raise exception when attempt to update without required parameters' do
# params = Models::ResourceGroup.new
# expect{@client.update(nil, params)}.to raise_error(ArgumentError)
# expect{@client.update('foo', nil)}.to raise_error(ArgumentError)
# expect{@client.update('~`123', params).value!}.to raise_error(MsRestAzure::AzureOperationError)
# end
#
# it 'should raise errors when attempting get resource group' do
# expect{@client.get_async(nil)}.to raise_error(ArgumentError)
# expect{@client.get_async('~`123').value!}.to raise_error(MsRestAzure::AzureOperationError)
# end
#
# it 'should return false when resource group does not not exists' do
# result = @client.check_existence_async('non-existence').value!
# expect(result.response.status).to eq(404)
# expect(result.body).to eq(false)
# end
#
# it 'should raise errors when attempting delete resource group' do
# expect{@client.delete(nil)}.to raise_error(ArgumentError)
# expect{@client.delete('~`123').value!}.to raise_error(MsRestAzure::AzureOperationError)
# end
#
# it 'should return false when check existence for not existing resource group' do
# resource_group_name = 'unknown_resource_group'
# expect(@client.check_existence_async(resource_group_name).value!.body).to eq(false)
# end
# end
#
# describe 'Resource Groups' do
# before(:each) do
# @resource_helper = ResourceHelper.new()
# @client = @resource_helper.resource_client.resource_groups
# @resource_group = @resource_helper.create_resource_group
# end
#
# after(:each) do
# @resource_helper.delete_resource_group(@resource_group.name)
# end
#
# it 'should get resource group' do
# result = @client.get_async(@resource_group.name).value!
#
# expect(result.body).not_to be_nil
# expect(result.body.id).not_to be_nil
# expect(result.body.name).to eq(@resource_group.name)
# expect(result.body.location).to eq('westus')
# expect(result.body.tags).to be_nil
# end
#
# it 'should list resource groups' do
# result = @client.list_async.value!
# expect(result.body.value).not_to be_nil
# expect(result.body.value).to be_a(Array)
#
# while !result.body.next_link.nil? && !result.body.next_link.empty? do
# result = @client.list_async(result.body.next_link).value!
# expect(result.body.value).not_to be_nil
# expect(result.body.value).to be_a(Array)
# end
# end
#
# it 'should check resource group exists' do
# result = @client.check_existence_async(@resource_group.name).value!.body
# expect(result).to be_truthy
# end
#
# it 'should list resource groups with tag_name and value filter and top parameter' do
# filter = "tagName eq 'tagName' and tagValue eq 'tagValue'"
# result = @client.list_async(filter, 1).value!
# expect(result.body.value).not_to be_nil
# expect(result.body.value).to be_a(Array)
#
# while !result.body.next_link.nil? && !result.body.next_link.empty? do
# result = @client.list_next_async(result.body.next_link).value!
# expect(result.body.value).not_to be_nil
# expect(result.body.value).to be_a(Array)
# end
# end
#
# it 'should resource groups with tag_name and value filter and top parameter' do
# filter = "tagName eq 'tagName' and tagValue eq 'tagValue'"
# result = @client.list_async(filter, 1).value!
# expect(result.body.value).not_to be_nil
# expect(result.body.value).to be_a(Array)
#
# while !result.body.next_link.nil? && !result.body.next_link.empty? do
# result = @client.list_next_async(result.body.next_link).value!
# expect(result.body.value).not_to be_nil
# expect(result.body.value).to be_a(Array)
# end
# end
# end

Просмотреть файл

@ -0,0 +1,72 @@
# # encoding: utf-8
# # Copyright (c) Microsoft Corporation. All rights reserved.
# # Licensed under the MIT License. See License.txt in the project root for license information.
#
# require_relative 'spec_helper'
#
# include MsRestAzure
# include Azure::ARM::Resources
#
# describe 'Tags' do
# let(:tag_name) { 'testtagname' }
# let(:tag_value) { 'testtagvalue' }
#
# before(:each) do
# @resource_help = ResourceHelper.new()
# @client = @resource_help.resource_client.tags
# @tag = @client.create_or_update_async(tag_name).value!
# end
#
# after(:each) do
# result = @client.delete_async(tag_name).value!
# expect(result.response.status).to eq(200)
# end
#
# it 'should create and delete tag' do
# result = @tag
#
# expect(result.body).not_to be_nil
# expect(result.body.id).not_to be_nil
# expect(result.body.tag_name).to eq(tag_name)
# expect(result.body.values).to be_a(Array)
# expect(result.body.count).to be_a(Models::TagCount)
# end
#
# it 'should create and delete tag with value' do
# tag = @tag.body
# result = @client.create_or_update_value_async(tag.tag_name, tag_value).value!
#
# expect(result.body).not_to be_nil
# expect(result.body.id).not_to be_nil
# expect(result.body.tag_value).to eq(tag_value)
# expect(result.body.count).to be_a(Models::TagCount)
#
# result = @client.delete_value_async(tag.tag_name, tag_value).value!
# expect(result.response.status).to eq(200)
# end
#
# it 'should list tags' do
# result = @client.list_async().value!
# expect(result.body.value).not_to be_nil
# expect(result.body.value).to be_a(Array)
#
# while !result.body.next_link.nil? && !result.body.next_link.empty? do
# result = @client.list_next(result.body.next_link).value!
# expect(result.body.value).not_to be_nil
# expect(result.body.value).to be_a(Array)
# end
# end
# end
#
# describe 'Tag raises' do
# before(:each) do
# @resource_help = ResourceHelper.new()
# @client = @resource_help.resource_client.tags
# end
#
# it 'an exception creating value for not existing tag' do
# tag_name = 'unknown_tag_name'
# tag_value = 'unknown_tag_value'
# expect {@client.create_or_update_value(tag_name, tag_value).value!}.to raise_error(MsRestAzure::AzureOperationError)
# end
# end

Просмотреть файл

@ -1,58 +0,0 @@
# encoding: utf-8
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
require_relative 'spec_helper'
include MsRestAzure
include Azure::ARM::Resources
describe 'Deployment Operations' do
before(:each) do
@resource_helper = ResourceHelper.new()
@client = @resource_helper.resource_client.deployment_operations
@resource_group = @resource_helper.create_resource_group
@deployment = @resource_helper.create_deployment(@resource_group.name)
@resource_helper.wait_for_deployment(@resource_group.name, @deployment.name, @resource_helper.build_deployment_params)
end
after(:each) do
@resource_helper.delete_resource_group(@resource_group.name)
end
it 'should get a list of deployment operations' do
result = @client.list_async(@resource_group.name, @deployment.name).value!
expect(result.response.status).to eq(200)
expect(result.body).not_to be_nil
expect(result.body.value).to be_a(Array)
while !result.body.next_link.nil? && !result.body.next_link.empty? do
result = @client.list_next(result.body.next_link).value!
expect(result.body.value).not_to be_nil
expect(result.body.value).to be_a(Array)
end
end
it 'should get a list of deployment operation restricted with top parameter' do
result = @client.list_async(@resource_group.name, @deployment.name, 1).value!
expect(result.response.status).to eq(200)
expect(result.body).not_to be_nil
expect(result.body.value).to be_a(Array)
while !result.body.next_link.nil? && !result.body.next_link.empty? do
result = @client.list_next_async(result.body.next_link).value!
expect(result.body.value).not_to be_nil
expect(result.body.value).to be_a(Array)
end
end
it 'should get a deployment operation' do
operations = @client.list_async(@resource_group.name, @deployment.name).value!.body.value
result = @client.get_async(@resource_group.name, @deployment.name, operations[0].operation_id).value!
expect(result.response.status).to eq(200)
expect(result.body.operation_id).to eq(operations[0].operation_id)
expect(result.body.id).not_to be_nil
expect(result.body.properties).to be_an_instance_of(Models::DeploymentOperationProperties)
end
end

Просмотреть файл

@ -1,103 +0,0 @@
# encoding: utf-8
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
require_relative 'spec_helper'
include MsRestAzure
include Azure::ARM::Resources
describe 'Template Deployments' do
before(:each) do
@resource_helper = ResourceHelper.new()
@client = @resource_helper.resource_client.deployments
@resource_group = @resource_helper.create_resource_group
end
after(:each) do
@resource_helper.delete_resource_group(@resource_group.name)
end
it 'should create template deployment' do
deployment_name = 'Deployment_test'
result = @client.create_or_update_async(@resource_group.name, deployment_name, @resource_helper.build_deployment_params).value!
expect(result.body.id).not_to be_nil
expect(result.body.name).to eq(deployment_name)
end
it 'should raise error when attempting to create with invalid parameters' do
expect{@client.create_or_update(nil, 'bar', @resource_helper.build_deployment_params)}.to raise_error(ArgumentError)
expect{@client.create_or_update('foo', nil, @resource_helper.build_deployment_params)}.to raise_error(ArgumentError)
expect{@client.create_or_update('foo', 'bar', nil)}.to raise_error(ArgumentError)
expect{@client.create_or_update('~`123', 'bar', @resource_helper.build_deployment_params).value!}.to raise_error(MsRestAzure::AzureOperationError)
end
it 'should cancel running template deployment' do
deployment = @resource_helper.begin_create_deployment(@resource_group.name)
result = @client.cancel_async(@resource_group.name, deployment.name).value!
expect(result.body).to be_nil
expect(result.response.status).to eq(204)
end
it 'should raise error when attempting cancel deployment with invalid parameters' do
expect{@client.cancel(nil, 'bar')}.to raise_error(ArgumentError)
expect{@client.cancel('foo', nil)}.to raise_error(ArgumentError)
end
it 'should get a deployment' do
deployment = @resource_helper.create_deployment(@resource_group.name)
result = @client.get_async(@resource_group.name, deployment.name).value!
expect(result.body.name).to eq(deployment.name)
end
it 'should raise error when attempting to get deployment with using invalid parameters' do
expect{@client.get(nil, 'bar')}.to raise_error(ArgumentError)
expect{@client.get('foo', nil)}.to raise_error(ArgumentError)
expect{@client.get('~`123', 'bar').value!}.to raise_error(MsRestAzure::AzureOperationError)
end
it 'should validate a deployment' do
deployment = @resource_helper.create_deployment(@resource_group.name)
@resource_helper.wait_for_deployment(@resource_group.name, deployment.name, @resource_helper.build_deployment_params)
result = @client.validate_async(@resource_group.name, deployment.name, @resource_helper.build_deployment_params).value!
expect(result.response.status).to eq(200)
end
it 'should raise error when attempting validate with invalid parameters' do
expect{@client.validate(nil, 'bar', @resource_helper.build_deployment_params)}.to raise_error(ArgumentError)
expect{@client.validate('foo', 'bar', nil)}.to raise_error(ArgumentError)
expect(@client.validate_async('~`123', 'bar', @resource_helper.build_deployment_params).value!.response.status).to eq(400)
end
it 'should get a list of deployments' do
result = @client.list_by_resource_group_async(@resource_group.name).value!
expect(result.body.value).not_to be_nil
expect(result.body.value).to be_a(Array)
while !result.body.next_link.nil? && !result.body.next_link.empty? do
result = @client.list_next(result.body.next_link).value!
expect(result.body.value).not_to be_nil
expect(result.body.value).to be_a(Array)
end
end
it 'should list filtered results restricted with top parameter' do
filter = "provisioningState eq 'Running'"
result = @client.list_by_resource_group_async(@resource_group.name, filter, 1).value!
expect(result.body.value).not_to be_nil
expect(result.body.value).to be_a(Array)
while !result.body.next_link.nil? && !result.body.next_link.empty?.empty? do
result = @client.list_next(result.body.next_link).value!
expect(result.body.value).not_to be_nil
expect(result.body.value).to be_a(Array)
end
end
end

Просмотреть файл

@ -1,106 +0,0 @@
# encoding: utf-8
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
require_relative 'spec_helper'
include MsRestAzure
include Azure::ARM::Resources
describe 'Providers' do
before(:each) do
@registered_providers = []
@unregistered_providers = []
@resource_helper = ResourceHelper.new()
@client = @resource_helper.resource_client.providers
end
after(:each) do
@registered_providers.each do |namespace|
begin
@client.unregister(namespace).value!
rescue Exception
end
end
@unregistered_providers.each do |namespace|
begin
@client.register(namespace).value!
rescue Exception
end
end
end
it 'should list providers' do
result = @client.list_async().value!
expect(result.body.value).not_to be_nil
expect(result.body.value).to be_a(Array)
while !result.body.next_link.nil? && !result.body.next_link.empty? do
result = @client.list_next_async(result.body.next_link).value!
expect(result.body.value).not_to be_nil
expect(result.body.value).to be_a(Array)
end
end
it 'should list providers with top restriction parameter' do
result = @client.list_async(1).value!
expect(result.body.value).not_to be_nil
expect(result.body.value).to be_a(Array)
while !result.body.next_link.nil? && !result.body.next_link.empty? do
result = @client.list_next(result.body.next_link).value!
expect(result.body.value).not_to be_nil
expect(result.body.value).to be_a(Array)
end
end
it 'should register provider' do
providers = @client.list_async().value!.body.value
targetProvider = providers.detect do |item|
item.registration_state == 'NotRegistered' || item.registration_state == 'Unregistered'
end
@registered_providers.push(targetProvider.namespace)
result = @client.register_async(targetProvider.namespace).value!
expect(result.response.status).to eq(200)
expect(result.body.namespace).to eq(targetProvider.namespace)
expect(result.body.registration_state).not_to eq('NotRegistered')
end
it 'should raise an error when attempting register provider with nil parameter' do
expect{@client.register(nil)}.to raise_error(ArgumentError)
end
it 'should unregister provider' do
providers = @client.list_async().value!.body.value
targetProvider = providers.detect {|item| item.registration_state == 'Registered' }
@unregistered_providers.push(targetProvider.namespace)
result = @client.unregister_async(targetProvider.namespace).value!
expect(result.response.status).to eq(200)
expect(result.body.namespace).to eq(targetProvider.namespace)
expect(result.body.registration_state).not_to eq('Registered')
end
it 'should raise an error when attempting unregister provider with nil parameter' do
expect{@client.unregister(nil)}.to raise_error(ArgumentError)
end
it 'should get provider' do
providers = @client.list_async().value!.body.value
result = @client.get_async(providers[0].namespace).value!
expect(result.body).not_to be_nil
expect(result.body.namespace).to eq(providers[0].namespace)
end
it 'should raise error when attempting get provider with nil parameter' do
expect{@client.get(nil)}.to raise_error(ArgumentError)
end
end

Просмотреть файл

@ -1,159 +0,0 @@
# encoding: utf-8
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
require_relative 'spec_helper'
include MsRestAzure
include Azure::ARM::Resources
describe 'Resource Groups' do
before(:each) do
@resource_helper = ResourceHelper.new()
@client = @resource_helper.resource_client.resource_groups
end
it 'should create and delete resource group' do
name = 'RubySDKTest_azure_mgmt_resources'
params = Models::ResourceGroup.new
params.location = 'westus'
params.tags = { 'tag1' => 'val1', 'tag2' => 'val2' }
result = @client.create_or_update_async(name, params).value!
expect(result.body).not_to be_nil
expect(result.body.id).not_to be_nil
expect(result.body.name).to eq(name)
expect(result.body.location).to eq('westus')
expect(result.body.tags).not_to be_nil
expect(result.body.tags['tag1']).to eq('val1')
expect(result.body.tags['tag2']).to eq('val2')
result = @client.delete_async(name).value!
expect(result.body).to be_nil
expect(result.response.status).to eq(200)
end
it 'should create resource group - using generic request' do
resource_client = @resource_helper.resource_client
name = 'RubySDKTest_azure_mgmt_resources'
request_content = "{'location':'westus','tags':{'tag1':'val1','tag2':'val2'}}"
subscription_id = ENV['AZURE_SUBSCRIPTION_ID']
path = "/subscriptions/#{subscription_id}/resourcegroups/#{name}?api-version=2016-09-01"
options = {
body: request_content
}
result = resource_client.make_request(:put, path, options)
expect(result['id']).not_to be_nil
expect(result['name']).to eq(name)
expect(result['location']).to eq('westus')
expect(result['tags']).not_to be_nil
expect(result['tags']['tag1']).to eq('val1')
expect(result['tags']['tag2']).to eq('val2')
end
it 'should throw exception when create or update with nil parameters' do
params = Models::ResourceGroup.new
expect{@client.create_or_update_async(nil, params)}.to raise_error(ArgumentError)
expect{@client.create_or_update_async('foo', nil)}.to raise_error(ArgumentError)
end
it 'should raise exception when attempt to update without required parameters' do
params = Models::ResourceGroup.new
expect{@client.update(nil, params)}.to raise_error(ArgumentError)
expect{@client.update('foo', nil)}.to raise_error(ArgumentError)
expect{@client.update('~`123', params).value!}.to raise_error(MsRestAzure::AzureOperationError)
end
it 'should raise errors when attempting get resource group' do
expect{@client.get_async(nil)}.to raise_error(ArgumentError)
expect{@client.get_async('~`123').value!}.to raise_error(MsRestAzure::AzureOperationError)
end
it 'should return false when resource group does not not exists' do
result = @client.check_existence_async('non-existence').value!
expect(result.response.status).to eq(404)
expect(result.body).to eq(false)
end
it 'should raise errors when attempting delete resource group' do
expect{@client.delete(nil)}.to raise_error(ArgumentError)
expect{@client.delete('~`123').value!}.to raise_error(MsRestAzure::AzureOperationError)
end
it 'should return false when check existence for not existing resource group' do
resource_group_name = 'unknown_resource_group'
expect(@client.check_existence_async(resource_group_name).value!.body).to eq(false)
end
end
describe 'Resource Groups' do
before(:each) do
@resource_helper = ResourceHelper.new()
@client = @resource_helper.resource_client.resource_groups
@resource_group = @resource_helper.create_resource_group
end
after(:each) do
@resource_helper.delete_resource_group(@resource_group.name)
end
it 'should get resource group' do
result = @client.get_async(@resource_group.name).value!
expect(result.body).not_to be_nil
expect(result.body.id).not_to be_nil
expect(result.body.name).to eq(@resource_group.name)
expect(result.body.location).to eq('westus')
expect(result.body.tags).to be_nil
end
it 'should list resource groups' do
result = @client.list_async.value!
expect(result.body.value).not_to be_nil
expect(result.body.value).to be_a(Array)
while !result.body.next_link.nil? && !result.body.next_link.empty? do
result = @client.list_async(result.body.next_link).value!
expect(result.body.value).not_to be_nil
expect(result.body.value).to be_a(Array)
end
end
it 'should check resource group exists' do
result = @client.check_existence_async(@resource_group.name).value!.body
expect(result).to be_truthy
end
it 'should list resource groups with tag_name and value filter and top parameter' do
filter = "tagName eq 'tagName' and tagValue eq 'tagValue'"
result = @client.list_async(filter, 1).value!
expect(result.body.value).not_to be_nil
expect(result.body.value).to be_a(Array)
while !result.body.next_link.nil? && !result.body.next_link.empty? do
result = @client.list_next_async(result.body.next_link).value!
expect(result.body.value).not_to be_nil
expect(result.body.value).to be_a(Array)
end
end
it 'should resource groups with tag_name and value filter and top parameter' do
filter = "tagName eq 'tagName' and tagValue eq 'tagValue'"
result = @client.list_async(filter, 1).value!
expect(result.body.value).not_to be_nil
expect(result.body.value).to be_a(Array)
while !result.body.next_link.nil? && !result.body.next_link.empty? do
result = @client.list_next_async(result.body.next_link).value!
expect(result.body.value).not_to be_nil
expect(result.body.value).to be_a(Array)
end
end
end

Просмотреть файл

@ -1,72 +0,0 @@
# encoding: utf-8
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
require_relative 'spec_helper'
include MsRestAzure
include Azure::ARM::Resources
describe 'Tags' do
let(:tag_name) { 'testtagname' }
let(:tag_value) { 'testtagvalue' }
before(:each) do
@resource_help = ResourceHelper.new()
@client = @resource_help.resource_client.tags
@tag = @client.create_or_update_async(tag_name).value!
end
after(:each) do
result = @client.delete_async(tag_name).value!
expect(result.response.status).to eq(200)
end
it 'should create and delete tag' do
result = @tag
expect(result.body).not_to be_nil
expect(result.body.id).not_to be_nil
expect(result.body.tag_name).to eq(tag_name)
expect(result.body.values).to be_a(Array)
expect(result.body.count).to be_a(Models::TagCount)
end
it 'should create and delete tag with value' do
tag = @tag.body
result = @client.create_or_update_value_async(tag.tag_name, tag_value).value!
expect(result.body).not_to be_nil
expect(result.body.id).not_to be_nil
expect(result.body.tag_value).to eq(tag_value)
expect(result.body.count).to be_a(Models::TagCount)
result = @client.delete_value_async(tag.tag_name, tag_value).value!
expect(result.response.status).to eq(200)
end
it 'should list tags' do
result = @client.list_async().value!
expect(result.body.value).not_to be_nil
expect(result.body.value).to be_a(Array)
while !result.body.next_link.nil? && !result.body.next_link.empty? do
result = @client.list_next(result.body.next_link).value!
expect(result.body.value).not_to be_nil
expect(result.body.value).to be_a(Array)
end
end
end
describe 'Tag raises' do
before(:each) do
@resource_help = ResourceHelper.new()
@client = @resource_help.resource_client.tags
end
it 'an exception creating value for not existing tag' do
tag_name = 'unknown_tag_name'
tag_value = 'unknown_tag_value'
expect {@client.create_or_update_value(tag_name, tag_value).value!}.to raise_error(MsRestAzure::AzureOperationError)
end
end