fog-ecloud 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +23 -0
- data/.rubocop.yml +20 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +17 -0
- data/CONTRIBUTING.md +18 -0
- data/CONTRIBUTORS.md +16 -0
- data/Gemfile +4 -0
- data/LICENSE.md +20 -0
- data/README.md +38 -0
- data/Rakefile +18 -0
- data/fog-ecloud.gemspec +35 -0
- data/gemfiles/Gemfile.1.9.2- +8 -0
- data/gemfiles/Gemfile.1.9.3+ +7 -0
- data/lib/fog/ecloud/collection.rb +24 -0
- data/lib/fog/ecloud/compute.rb +824 -0
- data/lib/fog/ecloud/core.rb +32 -0
- data/lib/fog/ecloud/generate_collection.rb +127 -0
- data/lib/fog/ecloud/ipaddr.rb +5 -0
- data/lib/fog/ecloud/mock_data_classes.rb +766 -0
- data/lib/fog/ecloud/model.rb +20 -0
- data/lib/fog/ecloud/models/compute/admin_organization.rb +43 -0
- data/lib/fog/ecloud/models/compute/admin_organizations.rb +21 -0
- data/lib/fog/ecloud/models/compute/api_key.rb +20 -0
- data/lib/fog/ecloud/models/compute/api_keys.rb +26 -0
- data/lib/fog/ecloud/models/compute/association.rb +23 -0
- data/lib/fog/ecloud/models/compute/associations.rb +34 -0
- data/lib/fog/ecloud/models/compute/authentication_level.rb +21 -0
- data/lib/fog/ecloud/models/compute/authentication_levels.rb +26 -0
- data/lib/fog/ecloud/models/compute/backup_internet_service.rb +45 -0
- data/lib/fog/ecloud/models/compute/backup_internet_services.rb +41 -0
- data/lib/fog/ecloud/models/compute/catalog.rb +39 -0
- data/lib/fog/ecloud/models/compute/catalog_configuration.rb +22 -0
- data/lib/fog/ecloud/models/compute/catalog_configurations.rb +26 -0
- data/lib/fog/ecloud/models/compute/catalog_item.rb +24 -0
- data/lib/fog/ecloud/models/compute/compute_pool.rb +70 -0
- data/lib/fog/ecloud/models/compute/compute_pools.rb +33 -0
- data/lib/fog/ecloud/models/compute/cpu_usage_detail.rb +16 -0
- data/lib/fog/ecloud/models/compute/cpu_usage_detail_summary.rb +26 -0
- data/lib/fog/ecloud/models/compute/detached_disk.rb +27 -0
- data/lib/fog/ecloud/models/compute/detached_disks.rb +26 -0
- data/lib/fog/ecloud/models/compute/environment.rb +111 -0
- data/lib/fog/ecloud/models/compute/environments.rb +39 -0
- data/lib/fog/ecloud/models/compute/firewall_acl.rb +27 -0
- data/lib/fog/ecloud/models/compute/firewall_acls.rb +27 -0
- data/lib/fog/ecloud/models/compute/group.rb +41 -0
- data/lib/fog/ecloud/models/compute/groups.rb +38 -0
- data/lib/fog/ecloud/models/compute/guest_process.rb +15 -0
- data/lib/fog/ecloud/models/compute/guest_processes.rb +26 -0
- data/lib/fog/ecloud/models/compute/hardware_configuration.rb +18 -0
- data/lib/fog/ecloud/models/compute/hardware_configurations.rb +26 -0
- data/lib/fog/ecloud/models/compute/internet_service.rb +97 -0
- data/lib/fog/ecloud/models/compute/internet_services.rb +44 -0
- data/lib/fog/ecloud/models/compute/ip_address.rb +39 -0
- data/lib/fog/ecloud/models/compute/ip_addresses.rb +32 -0
- data/lib/fog/ecloud/models/compute/layout.rb +20 -0
- data/lib/fog/ecloud/models/compute/layouts.rb +26 -0
- data/lib/fog/ecloud/models/compute/location.rb +22 -0
- data/lib/fog/ecloud/models/compute/locations.rb +28 -0
- data/lib/fog/ecloud/models/compute/login_banner.rb +16 -0
- data/lib/fog/ecloud/models/compute/login_banners.rb +26 -0
- data/lib/fog/ecloud/models/compute/memory_usage_detail.rb +16 -0
- data/lib/fog/ecloud/models/compute/memory_usage_detail_summary.rb +26 -0
- data/lib/fog/ecloud/models/compute/monitor.rb +46 -0
- data/lib/fog/ecloud/models/compute/monitors.rb +30 -0
- data/lib/fog/ecloud/models/compute/network.rb +46 -0
- data/lib/fog/ecloud/models/compute/networks.rb +32 -0
- data/lib/fog/ecloud/models/compute/node.rb +45 -0
- data/lib/fog/ecloud/models/compute/nodes.rb +42 -0
- data/lib/fog/ecloud/models/compute/operating_system.rb +16 -0
- data/lib/fog/ecloud/models/compute/operating_system_families.rb +26 -0
- data/lib/fog/ecloud/models/compute/operating_system_family.rb +21 -0
- data/lib/fog/ecloud/models/compute/operating_systems.rb +25 -0
- data/lib/fog/ecloud/models/compute/organization.rb +78 -0
- data/lib/fog/ecloud/models/compute/organizations.rb +38 -0
- data/lib/fog/ecloud/models/compute/password_complexity_rule.rb +49 -0
- data/lib/fog/ecloud/models/compute/password_complexity_rules.rb +26 -0
- data/lib/fog/ecloud/models/compute/physical_device.rb +21 -0
- data/lib/fog/ecloud/models/compute/physical_devices.rb +26 -0
- data/lib/fog/ecloud/models/compute/public_ip.rb +26 -0
- data/lib/fog/ecloud/models/compute/public_ips.rb +31 -0
- data/lib/fog/ecloud/models/compute/rnat.rb +27 -0
- data/lib/fog/ecloud/models/compute/rnats.rb +26 -0
- data/lib/fog/ecloud/models/compute/role.rb +23 -0
- data/lib/fog/ecloud/models/compute/roles.rb +36 -0
- data/lib/fog/ecloud/models/compute/row.rb +56 -0
- data/lib/fog/ecloud/models/compute/rows.rb +39 -0
- data/lib/fog/ecloud/models/compute/server.rb +323 -0
- data/lib/fog/ecloud/models/compute/server_configuration_option.rb +16 -0
- data/lib/fog/ecloud/models/compute/server_configuration_options.rb +26 -0
- data/lib/fog/ecloud/models/compute/servers.rb +65 -0
- data/lib/fog/ecloud/models/compute/ssh_key.rb +19 -0
- data/lib/fog/ecloud/models/compute/ssh_keys.rb +26 -0
- data/lib/fog/ecloud/models/compute/storage_usage_detail.rb +16 -0
- data/lib/fog/ecloud/models/compute/storage_usage_detail_summary.rb +26 -0
- data/lib/fog/ecloud/models/compute/support_ticket.rb +28 -0
- data/lib/fog/ecloud/models/compute/support_tickets.rb +26 -0
- data/lib/fog/ecloud/models/compute/tag.rb +13 -0
- data/lib/fog/ecloud/models/compute/tags.rb +26 -0
- data/lib/fog/ecloud/models/compute/task.rb +23 -0
- data/lib/fog/ecloud/models/compute/tasks.rb +29 -0
- data/lib/fog/ecloud/models/compute/template.rb +23 -0
- data/lib/fog/ecloud/models/compute/templates.rb +41 -0
- data/lib/fog/ecloud/models/compute/trusted_network_group.rb +33 -0
- data/lib/fog/ecloud/models/compute/trusted_network_groups.rb +27 -0
- data/lib/fog/ecloud/models/compute/user.rb +35 -0
- data/lib/fog/ecloud/models/compute/users.rb +26 -0
- data/lib/fog/ecloud/models/compute/virtual_machine_assigned_ip.rb +32 -0
- data/lib/fog/ecloud/models/compute/virtual_machine_assigned_ips.rb +26 -0
- data/lib/fog/ecloud/requests/compute/admin_disable_support_access.rb +9 -0
- data/lib/fog/ecloud/requests/compute/admin_edit_authentication_levels.rb +32 -0
- data/lib/fog/ecloud/requests/compute/admin_edit_login_banner.rb +30 -0
- data/lib/fog/ecloud/requests/compute/admin_edit_password_complexity_rules.rb +72 -0
- data/lib/fog/ecloud/requests/compute/admin_enable_support_access.rb +9 -0
- data/lib/fog/ecloud/requests/compute/backup_internet_service_create.rb +47 -0
- data/lib/fog/ecloud/requests/compute/backup_internet_service_delete.rb +9 -0
- data/lib/fog/ecloud/requests/compute/backup_internet_service_edit.rb +47 -0
- data/lib/fog/ecloud/requests/compute/compute_pool_edit.rb +35 -0
- data/lib/fog/ecloud/requests/compute/firewall_acls_create.rb +78 -0
- data/lib/fog/ecloud/requests/compute/firewall_acls_delete.rb +9 -0
- data/lib/fog/ecloud/requests/compute/get_admin_organization.rb +23 -0
- data/lib/fog/ecloud/requests/compute/get_api_key.rb +9 -0
- data/lib/fog/ecloud/requests/compute/get_api_keys.rb +9 -0
- data/lib/fog/ecloud/requests/compute/get_association.rb +9 -0
- data/lib/fog/ecloud/requests/compute/get_associations.rb +9 -0
- data/lib/fog/ecloud/requests/compute/get_authentication_level.rb +9 -0
- data/lib/fog/ecloud/requests/compute/get_authentication_levels.rb +9 -0
- data/lib/fog/ecloud/requests/compute/get_backup_internet_service.rb +9 -0
- data/lib/fog/ecloud/requests/compute/get_backup_internet_services.rb +9 -0
- data/lib/fog/ecloud/requests/compute/get_catalog.rb +9 -0
- data/lib/fog/ecloud/requests/compute/get_catalog_configuration.rb +9 -0
- data/lib/fog/ecloud/requests/compute/get_catalog_configurations.rb +9 -0
- data/lib/fog/ecloud/requests/compute/get_catalog_item.rb +9 -0
- data/lib/fog/ecloud/requests/compute/get_compute_pool.rb +21 -0
- data/lib/fog/ecloud/requests/compute/get_compute_pools.rb +31 -0
- data/lib/fog/ecloud/requests/compute/get_cpu_usage_detail.rb +9 -0
- data/lib/fog/ecloud/requests/compute/get_cpu_usage_detail_summary.rb +9 -0
- data/lib/fog/ecloud/requests/compute/get_detached_disk.rb +21 -0
- data/lib/fog/ecloud/requests/compute/get_detached_disks.rb +31 -0
- data/lib/fog/ecloud/requests/compute/get_environment.rb +31 -0
- data/lib/fog/ecloud/requests/compute/get_environments.rb +0 -0
- data/lib/fog/ecloud/requests/compute/get_firewall_acl.rb +9 -0
- data/lib/fog/ecloud/requests/compute/get_firewall_acls.rb +9 -0
- data/lib/fog/ecloud/requests/compute/get_group.rb +18 -0
- data/lib/fog/ecloud/requests/compute/get_groups.rb +18 -0
- data/lib/fog/ecloud/requests/compute/get_guest_process.rb +9 -0
- data/lib/fog/ecloud/requests/compute/get_guest_processes.rb +9 -0
- data/lib/fog/ecloud/requests/compute/get_hardware_configuration.rb +29 -0
- data/lib/fog/ecloud/requests/compute/get_hardware_configurations.rb +14 -0
- data/lib/fog/ecloud/requests/compute/get_internet_service.rb +21 -0
- data/lib/fog/ecloud/requests/compute/get_internet_services.rb +18 -0
- data/lib/fog/ecloud/requests/compute/get_ip_address.rb +20 -0
- data/lib/fog/ecloud/requests/compute/get_layout.rb +18 -0
- data/lib/fog/ecloud/requests/compute/get_layouts.rb +18 -0
- data/lib/fog/ecloud/requests/compute/get_location.rb +9 -0
- data/lib/fog/ecloud/requests/compute/get_locations.rb +9 -0
- data/lib/fog/ecloud/requests/compute/get_login_banner.rb +9 -0
- data/lib/fog/ecloud/requests/compute/get_login_banners.rb +9 -0
- data/lib/fog/ecloud/requests/compute/get_memory_usage_detail.rb +9 -0
- data/lib/fog/ecloud/requests/compute/get_memory_usage_detail_summary.rb +9 -0
- data/lib/fog/ecloud/requests/compute/get_monitor.rb +9 -0
- data/lib/fog/ecloud/requests/compute/get_monitors.rb +9 -0
- data/lib/fog/ecloud/requests/compute/get_network.rb +21 -0
- data/lib/fog/ecloud/requests/compute/get_network_summary.rb +9 -0
- data/lib/fog/ecloud/requests/compute/get_networks.rb +30 -0
- data/lib/fog/ecloud/requests/compute/get_node.rb +21 -0
- data/lib/fog/ecloud/requests/compute/get_nodes.rb +18 -0
- data/lib/fog/ecloud/requests/compute/get_operating_system.rb +24 -0
- data/lib/fog/ecloud/requests/compute/get_operating_system_families.rb +30 -0
- data/lib/fog/ecloud/requests/compute/get_organization.rb +24 -0
- data/lib/fog/ecloud/requests/compute/get_organizations.rb +23 -0
- data/lib/fog/ecloud/requests/compute/get_password_complexity_rule.rb +9 -0
- data/lib/fog/ecloud/requests/compute/get_password_complexity_rules.rb +9 -0
- data/lib/fog/ecloud/requests/compute/get_physical_device.rb +9 -0
- data/lib/fog/ecloud/requests/compute/get_physical_devices.rb +9 -0
- data/lib/fog/ecloud/requests/compute/get_process.rb +9 -0
- data/lib/fog/ecloud/requests/compute/get_processes.rb +9 -0
- data/lib/fog/ecloud/requests/compute/get_public_ip.rb +21 -0
- data/lib/fog/ecloud/requests/compute/get_public_ips.rb +31 -0
- data/lib/fog/ecloud/requests/compute/get_rnat.rb +9 -0
- data/lib/fog/ecloud/requests/compute/get_rnats.rb +9 -0
- data/lib/fog/ecloud/requests/compute/get_role.rb +9 -0
- data/lib/fog/ecloud/requests/compute/get_roles.rb +9 -0
- data/lib/fog/ecloud/requests/compute/get_row.rb +18 -0
- data/lib/fog/ecloud/requests/compute/get_rows.rb +12 -0
- data/lib/fog/ecloud/requests/compute/get_server.rb +21 -0
- data/lib/fog/ecloud/requests/compute/get_server_configuration_option.rb +9 -0
- data/lib/fog/ecloud/requests/compute/get_server_configuration_options.rb +9 -0
- data/lib/fog/ecloud/requests/compute/get_servers.rb +42 -0
- data/lib/fog/ecloud/requests/compute/get_ssh_key.rb +21 -0
- data/lib/fog/ecloud/requests/compute/get_ssh_keys.rb +30 -0
- data/lib/fog/ecloud/requests/compute/get_storage_usage_detail.rb +9 -0
- data/lib/fog/ecloud/requests/compute/get_storage_usage_detail_summary.rb +9 -0
- data/lib/fog/ecloud/requests/compute/get_support_ticket.rb +9 -0
- data/lib/fog/ecloud/requests/compute/get_support_tickets.rb +9 -0
- data/lib/fog/ecloud/requests/compute/get_tag.rb +9 -0
- data/lib/fog/ecloud/requests/compute/get_tags.rb +9 -0
- data/lib/fog/ecloud/requests/compute/get_task.rb +13 -0
- data/lib/fog/ecloud/requests/compute/get_tasks.rb +9 -0
- data/lib/fog/ecloud/requests/compute/get_template.rb +21 -0
- data/lib/fog/ecloud/requests/compute/get_templates.rb +48 -0
- data/lib/fog/ecloud/requests/compute/get_trusted_network_group.rb +9 -0
- data/lib/fog/ecloud/requests/compute/get_trusted_network_groups.rb +9 -0
- data/lib/fog/ecloud/requests/compute/get_user.rb +9 -0
- data/lib/fog/ecloud/requests/compute/get_users.rb +9 -0
- data/lib/fog/ecloud/requests/compute/get_virtual_machine_assigned_ips.rb +42 -0
- data/lib/fog/ecloud/requests/compute/groups_create.rb +31 -0
- data/lib/fog/ecloud/requests/compute/groups_delete.rb +26 -0
- data/lib/fog/ecloud/requests/compute/groups_edit.rb +29 -0
- data/lib/fog/ecloud/requests/compute/groups_movedown.rb +9 -0
- data/lib/fog/ecloud/requests/compute/groups_moveup.rb +9 -0
- data/lib/fog/ecloud/requests/compute/internet_service_create.rb +102 -0
- data/lib/fog/ecloud/requests/compute/internet_service_delete.rb +33 -0
- data/lib/fog/ecloud/requests/compute/internet_service_edit.rb +58 -0
- data/lib/fog/ecloud/requests/compute/monitors_create_default.rb +9 -0
- data/lib/fog/ecloud/requests/compute/monitors_create_ecv.rb +40 -0
- data/lib/fog/ecloud/requests/compute/monitors_create_http.rb +44 -0
- data/lib/fog/ecloud/requests/compute/monitors_create_loopback.rb +9 -0
- data/lib/fog/ecloud/requests/compute/monitors_create_ping.rb +35 -0
- data/lib/fog/ecloud/requests/compute/monitors_disable.rb +9 -0
- data/lib/fog/ecloud/requests/compute/monitors_edit_ecv.rb +40 -0
- data/lib/fog/ecloud/requests/compute/monitors_edit_http.rb +44 -0
- data/lib/fog/ecloud/requests/compute/monitors_edit_ping.rb +35 -0
- data/lib/fog/ecloud/requests/compute/monitors_enable.rb +9 -0
- data/lib/fog/ecloud/requests/compute/node_service_create.rb +93 -0
- data/lib/fog/ecloud/requests/compute/node_service_delete.rb +33 -0
- data/lib/fog/ecloud/requests/compute/node_service_edit.rb +39 -0
- data/lib/fog/ecloud/requests/compute/power_off.rb +9 -0
- data/lib/fog/ecloud/requests/compute/power_on.rb +9 -0
- data/lib/fog/ecloud/requests/compute/power_reset.rb +9 -0
- data/lib/fog/ecloud/requests/compute/power_shutdown.rb +9 -0
- data/lib/fog/ecloud/requests/compute/public_ip_activate.rb +9 -0
- data/lib/fog/ecloud/requests/compute/rnat_associations_create_device.rb +32 -0
- data/lib/fog/ecloud/requests/compute/rnat_associations_delete.rb +9 -0
- data/lib/fog/ecloud/requests/compute/rnat_associations_edit_network.rb +31 -0
- data/lib/fog/ecloud/requests/compute/rows_create.rb +29 -0
- data/lib/fog/ecloud/requests/compute/rows_delete.rb +21 -0
- data/lib/fog/ecloud/requests/compute/rows_edit.rb +29 -0
- data/lib/fog/ecloud/requests/compute/rows_movedown.rb +9 -0
- data/lib/fog/ecloud/requests/compute/rows_moveup.rb +9 -0
- data/lib/fog/ecloud/requests/compute/trusted_network_groups_create.rb +51 -0
- data/lib/fog/ecloud/requests/compute/trusted_network_groups_delete.rb +9 -0
- data/lib/fog/ecloud/requests/compute/trusted_network_groups_edit.rb +51 -0
- data/lib/fog/ecloud/requests/compute/virtual_machine_attach_disk.rb +61 -0
- data/lib/fog/ecloud/requests/compute/virtual_machine_copy.rb +116 -0
- data/lib/fog/ecloud/requests/compute/virtual_machine_copy_identical.rb +43 -0
- data/lib/fog/ecloud/requests/compute/virtual_machine_create_from_template.rb +244 -0
- data/lib/fog/ecloud/requests/compute/virtual_machine_delete.rb +46 -0
- data/lib/fog/ecloud/requests/compute/virtual_machine_detach_disk.rb +70 -0
- data/lib/fog/ecloud/requests/compute/virtual_machine_edit.rb +45 -0
- data/lib/fog/ecloud/requests/compute/virtual_machine_edit_assigned_ips.rb +80 -0
- data/lib/fog/ecloud/requests/compute/virtual_machine_edit_hardware_configuration.rb +75 -0
- data/lib/fog/ecloud/requests/compute/virtual_machine_import.rb +179 -0
- data/lib/fog/ecloud/requests/compute/virtual_machine_upload_file.rb +28 -0
- data/lib/fog/ecloud/version.rb +5 -0
- data/lib/fog/ecloud.rb +8 -0
- data/spec/minitest_helper.rb +31 -0
- data/tests/compute/helper.rb +27 -0
- data/tests/compute/models/admin_organization_tests.rb +16 -0
- data/tests/compute/models/compute_pool_tests.rb +17 -0
- data/tests/compute/models/detached_disk_tests.rb +26 -0
- data/tests/compute/models/environment_tests.rb +23 -0
- data/tests/compute/models/internet_service_tests.rb +28 -0
- data/tests/compute/models/ip_address_tests.rb +19 -0
- data/tests/compute/models/network_tests.rb +17 -0
- data/tests/compute/models/operating_system_families_tests.rb +13 -0
- data/tests/compute/models/operating_system_tests.rb +22 -0
- data/tests/compute/models/organization_tests.rb +21 -0
- data/tests/compute/models/public_ip_tests.rb +19 -0
- data/tests/compute/models/server_tests.rb +25 -0
- data/tests/compute/models/ssh_key_tests.rb +19 -0
- data/tests/compute/models/template_tests.rb +20 -0
- data/tests/helper.rb +24 -0
- data/tests/helpers/collection_helper.rb +97 -0
- data/tests/helpers/compute/flavors_helper.rb +32 -0
- data/tests/helpers/compute/server_helper.rb +25 -0
- data/tests/helpers/compute/servers_helper.rb +10 -0
- data/tests/helpers/formats_helper.rb +98 -0
- data/tests/helpers/formats_helper_tests.rb +110 -0
- data/tests/helpers/mock_helper.rb +115 -0
- data/tests/helpers/model_helper.rb +31 -0
- data/tests/helpers/responds_to_helper.rb +11 -0
- data/tests/helpers/schema_validator_tests.rb +107 -0
- data/tests/helpers/succeeds_helper.rb +9 -0
- metadata +457 -0
@@ -0,0 +1,23 @@
|
|
1
|
+
provider, config = :ecloud, compute_providers[:ecloud]
|
2
|
+
|
3
|
+
Shindo.tests("Fog::Compute[:#{provider}] | environments", [provider.to_s]) do
|
4
|
+
connection = Fog::Compute[provider]
|
5
|
+
@organization = connection.organizations.first
|
6
|
+
|
7
|
+
tests('#all').succeeds do
|
8
|
+
returns(false) { @organization.environments.all.empty? }
|
9
|
+
end
|
10
|
+
|
11
|
+
tests('#get').succeeds do
|
12
|
+
environment = @organization.environments.all.first
|
13
|
+
fetched_environment = connection.environments.get(environment.href)
|
14
|
+
|
15
|
+
returns(true) { !fetched_environment.nil? }
|
16
|
+
end
|
17
|
+
|
18
|
+
tests("#organization").succeeds do
|
19
|
+
environment = @organization.environments.all.first
|
20
|
+
returns(false, "returns an organization") { environment.organization.nil? }
|
21
|
+
returns(true, "returns correct organization") { environment.organization.href == @organization.href }
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
provider, config = :ecloud, compute_providers[:ecloud]
|
2
|
+
|
3
|
+
Shindo.tests("Fog::Compute[:#{provider}] | internet_services", [provider.to_s, "queries"]) do
|
4
|
+
connection = Fog::Compute[provider]
|
5
|
+
organization = connection.organizations.first
|
6
|
+
environment = organization.environments.find { |e| e.name == config[:ecloud_environment_name] } || organization.environments.first
|
7
|
+
public_ips = environment.public_ips
|
8
|
+
public_ip = public_ips.find { |i| i.name == config[:ecloud_public_ip_name] } || public_ips.first
|
9
|
+
@internet_services = public_ip.internet_services
|
10
|
+
|
11
|
+
tests('#all').succeeds do
|
12
|
+
returns(true, "is a collection") { @internet_services.is_a?(Fog::Compute::Ecloud::InternetServices) }
|
13
|
+
if Fog.mocking?
|
14
|
+
returns(false, "has services") { @internet_services.empty? }
|
15
|
+
else
|
16
|
+
true
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
unless @internet_services.empty?
|
21
|
+
tests('#get').succeeds do
|
22
|
+
service = @internet_services.first
|
23
|
+
fetched_service = connection.internet_services.get(service.href)
|
24
|
+
returns(false, "service is not nil") { fetched_service.nil? }
|
25
|
+
returns(true, "is an InternetService") { fetched_service.is_a?(Fog::Compute::Ecloud::InternetService) }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
provider, config = :ecloud, compute_providers[:ecloud]
|
2
|
+
|
3
|
+
Shindo.tests("Fog::Compute[:#{provider}] | ip_addresses", [provider.to_s]) do
|
4
|
+
connection = Fog::Compute[provider]
|
5
|
+
@organization = connection.organizations.first
|
6
|
+
@environment = @organization.environments.first
|
7
|
+
@network = @environment.networks.first
|
8
|
+
@ip_addresses = @network.ips
|
9
|
+
|
10
|
+
tests('#all').succeeds do
|
11
|
+
returns(false) { @ip_addresses.all.empty? }
|
12
|
+
end
|
13
|
+
|
14
|
+
tests('#get').succeeds do
|
15
|
+
address = @ip_addresses.first
|
16
|
+
fetched_network = connection.ip_addresses.get(address.href)
|
17
|
+
returns(false) { fetched_network.nil? }
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
provider, config = :ecloud, compute_providers[:ecloud]
|
2
|
+
|
3
|
+
Shindo.tests("Fog::Compute[:#{provider}] | networks", [provider.to_s]) do
|
4
|
+
connection = Fog::Compute[provider]
|
5
|
+
@organization = connection.organizations.first
|
6
|
+
@environment = @organization.environments.first
|
7
|
+
|
8
|
+
tests('#all').succeeds do
|
9
|
+
returns(false) { @environment.networks.all.empty? }
|
10
|
+
end
|
11
|
+
|
12
|
+
tests('#get').succeeds do
|
13
|
+
network = @environment.networks.all.first
|
14
|
+
fetched_network = connection.networks.get(network.href)
|
15
|
+
returns(true) { !fetched_network.nil? }
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
provider, config = :ecloud, compute_providers[:ecloud]
|
2
|
+
|
3
|
+
Shindo.tests("Fog::Compute[:#{provider}] | operating_system_families", [provider.to_s]) do
|
4
|
+
connection = Fog::Compute[provider]
|
5
|
+
@organization = connection.organizations.first
|
6
|
+
@environment = @organization.environments.find{|e| e.name == config[:server_attributes][:environment_name]} || @organization.environments.first
|
7
|
+
@compute_pool = @environment.compute_pools.first
|
8
|
+
|
9
|
+
tests('#all').succeeds do
|
10
|
+
operating_system_families = @compute_pool.operating_system_families
|
11
|
+
returns(false) { operating_system_families.empty? }
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
provider, config = :ecloud, compute_providers[:ecloud]
|
2
|
+
|
3
|
+
Shindo.tests("Fog::Compute[:#{provider}] | operating_system", [provider.to_s]) do
|
4
|
+
connection = Fog::Compute[provider]
|
5
|
+
@organization = connection.organizations.first
|
6
|
+
@environment = @organization.environments.find{|e| e.name == config[:server_attributes][:environment_name]} || @organization.environments.first
|
7
|
+
@compute_pool = @environment.compute_pools.first
|
8
|
+
|
9
|
+
tests('#all').succeeds do
|
10
|
+
family = @compute_pool.operating_system_families.first
|
11
|
+
operating_systems = family.operating_systems
|
12
|
+
|
13
|
+
returns(false) { operating_systems.empty? }
|
14
|
+
end
|
15
|
+
|
16
|
+
tests('#get').succeeds do
|
17
|
+
family = @compute_pool.operating_system_families.first
|
18
|
+
operating_system = family.operating_systems.first
|
19
|
+
|
20
|
+
returns(false) { family.operating_systems.get(operating_system.href).nil? }
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
provider, config = :ecloud, compute_providers[:ecloud]
|
2
|
+
|
3
|
+
Shindo.tests("Fog::Compute[:#{provider}] | organizations", [provider.to_s]) do
|
4
|
+
connection = Fog::Compute[provider]
|
5
|
+
|
6
|
+
tests('#all').succeeds do
|
7
|
+
returns(false) { connection.organizations.all.empty? }
|
8
|
+
end
|
9
|
+
|
10
|
+
tests('#get').succeeds do
|
11
|
+
organization = connection.organizations.all.first
|
12
|
+
fetched_organization = connection.organizations.get(organization.href)
|
13
|
+
returns(true) { !fetched_organization.nil? }
|
14
|
+
end
|
15
|
+
|
16
|
+
tests("#admin").succeeds do
|
17
|
+
organization = connection.organizations.all.first
|
18
|
+
|
19
|
+
returns(true, "return AdminOrganization") { organization.admin.is_a?(Fog::Compute::Ecloud::AdminOrganization) }
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
provider, config = :ecloud, compute_providers[:ecloud]
|
2
|
+
|
3
|
+
Shindo.tests("Fog::Compute[:#{provider}] | ip_addresses", [provider.to_s]) do
|
4
|
+
connection = Fog::Compute[provider]
|
5
|
+
@organization = connection.organizations.first
|
6
|
+
@environment = @organization.environments.first
|
7
|
+
@public_ips = @environment.public_ips
|
8
|
+
|
9
|
+
tests('#all').succeeds do
|
10
|
+
returns(false, "has ips") { @public_ips.all.empty? }
|
11
|
+
end
|
12
|
+
|
13
|
+
tests('#get').succeeds do
|
14
|
+
address = @public_ips.first
|
15
|
+
fetched_ip = connection.public_ips.get(address.href)
|
16
|
+
returns(false, "ip is not nil") { fetched_ip.nil? }
|
17
|
+
returns(true, "is a PublicIp") { fetched_ip.is_a?(Fog::Compute::Ecloud::PublicIp) }
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
provider, config = :ecloud, compute_providers[:ecloud]
|
2
|
+
|
3
|
+
Shindo.tests("Fog::Compute[:#{provider}] | server", [provider.to_s, "attributes"]) do
|
4
|
+
connection = Fog::Compute[provider]
|
5
|
+
connection.base_path = '/cloudapi/spec'
|
6
|
+
organization = connection.organizations.first
|
7
|
+
environment = organization.environments.find{|e| e.name == config[:server_attributes][:environment_name]} || organization.environments.first
|
8
|
+
public_ip = environment.public_ips.first
|
9
|
+
compute_pool = environment.compute_pools.first
|
10
|
+
image_href = Fog.credentials[:ecloud_image_href] || compute_pool.templates.first.href
|
11
|
+
ssh_key = organization.admin.ssh_keys.find { |key| key.name == "root" }
|
12
|
+
|
13
|
+
@network = environment.networks.first
|
14
|
+
options = config[:server_attributes].merge(:network_uri => @network.href, :ssh_key_uri => ssh_key.href)
|
15
|
+
#if Fog.credentials[:ecloud_ssh_key_id]
|
16
|
+
# options = options.merge(:ssh_key_uri => "/cloudapi/ecloud/admin/sshkeys/#{Fog.credentials[:ecloud_ssh_key_id]}")
|
17
|
+
#end
|
18
|
+
|
19
|
+
@server = compute_pool.servers.first || compute_pool.servers.create(image_href, options).tap{|s| s.wait_for { ready? }}
|
20
|
+
|
21
|
+
tests('#ip_addresses').succeeds do
|
22
|
+
returns(true, "is an array") { @server.ips.is_a?(Array) }
|
23
|
+
returns(true, "contains an VirtualMachineAssignedIp") { @server.ips.all?{|ip| ip.is_a?(Fog::Compute::Ecloud::VirtualMachineAssignedIp) } }
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
provider, config = :ecloud, compute_providers[:ecloud]
|
2
|
+
|
3
|
+
Shindo.tests("Fog::Compute[:#{provider}] | ssh_keys", [provider.to_s]) do
|
4
|
+
connection = Fog::Compute[provider]
|
5
|
+
@organization = connection.organizations.first
|
6
|
+
@admin_organization = @organization.admin
|
7
|
+
@admin_organization.reload
|
8
|
+
@ssh_keys = @admin_organization.ssh_keys
|
9
|
+
|
10
|
+
tests('#all').succeeds do
|
11
|
+
returns(false) { @ssh_keys.empty? }
|
12
|
+
end
|
13
|
+
|
14
|
+
tests('#get').succeeds do
|
15
|
+
ssh_key = @ssh_keys.first
|
16
|
+
|
17
|
+
returns(false) { @ssh_keys.get(ssh_key.href).nil? }
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
provider, config = :ecloud, compute_providers[:ecloud]
|
2
|
+
|
3
|
+
Shindo.tests("Fog::Compute[:#{provider}] | templates", [provider.to_s]) do
|
4
|
+
connection = Fog::Compute[provider]
|
5
|
+
@organization = connection.organizations.first
|
6
|
+
@environment = @organization.environments.find{|e| e.name == config[:server_attributes][:environment_name]} || @organization.environments.first
|
7
|
+
@compute_pool = @environment.compute_pools.first
|
8
|
+
|
9
|
+
tests('#all').succeeds do
|
10
|
+
templates = @compute_pool.templates
|
11
|
+
returns(false) { templates.empty? }
|
12
|
+
end
|
13
|
+
|
14
|
+
tests('#get').succeeds do
|
15
|
+
templates = @compute_pool.templates
|
16
|
+
template = templates.first
|
17
|
+
|
18
|
+
returns(false) { @compute_pool.templates.get(template.href).nil? }
|
19
|
+
end
|
20
|
+
end
|
data/tests/helper.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
if ENV['COVERAGE']
|
2
|
+
require 'coveralls'
|
3
|
+
require 'simplecov'
|
4
|
+
|
5
|
+
SimpleCov.start do
|
6
|
+
add_filter '/spec/'
|
7
|
+
add_filter '/test/'
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
require 'fog/ecloud'
|
12
|
+
|
13
|
+
Excon.defaults.merge!(:debug_request => true, :debug_response => true)
|
14
|
+
|
15
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'helpers', 'mock_helper'))
|
16
|
+
|
17
|
+
# This overrides the default 600 seconds timeout during live test runs
|
18
|
+
if Fog.mocking?
|
19
|
+
FOG_TESTING_TIMEOUT = ENV['FOG_TEST_TIMEOUT'] || 2000
|
20
|
+
Fog.timeout = 2000
|
21
|
+
Fog::Logger.warning "Setting default fog timeout to #{Fog.timeout} seconds"
|
22
|
+
else
|
23
|
+
FOG_TESTING_TIMEOUT = Fog.timeout
|
24
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
def collection_tests(collection, params = {}, mocks_implemented = true)
|
2
|
+
tests('success') do
|
3
|
+
|
4
|
+
tests("#new(#{params.inspect})").succeeds do
|
5
|
+
pending if Fog.mocking? && !mocks_implemented
|
6
|
+
collection.new(params)
|
7
|
+
end
|
8
|
+
|
9
|
+
tests("#create(#{params.inspect})").succeeds do
|
10
|
+
pending if Fog.mocking? && !mocks_implemented
|
11
|
+
@instance = collection.create(params)
|
12
|
+
end
|
13
|
+
# FIXME: work around for timing issue on AWS describe_instances mocks
|
14
|
+
|
15
|
+
if Fog.mocking? && @instance.respond_to?(:ready?)
|
16
|
+
@instance.wait_for { ready? }
|
17
|
+
end
|
18
|
+
|
19
|
+
tests("#all").succeeds do
|
20
|
+
pending if Fog.mocking? && !mocks_implemented
|
21
|
+
collection.all
|
22
|
+
end
|
23
|
+
|
24
|
+
if !Fog.mocking? || mocks_implemented
|
25
|
+
@identity = @instance.identity
|
26
|
+
end
|
27
|
+
|
28
|
+
tests("#get(#{@identity})").succeeds do
|
29
|
+
pending if Fog.mocking? && !mocks_implemented
|
30
|
+
collection.get(@identity)
|
31
|
+
end
|
32
|
+
|
33
|
+
tests('Enumerable') do
|
34
|
+
pending if Fog.mocking? && !mocks_implemented
|
35
|
+
|
36
|
+
methods = [
|
37
|
+
'all?', 'any?', 'find', 'detect', 'collect', 'map',
|
38
|
+
'find_index', 'flat_map', 'collect_concat', 'group_by',
|
39
|
+
'none?', 'one?'
|
40
|
+
]
|
41
|
+
|
42
|
+
# JRuby 1.7.5+ issue causes a SystemStackError: stack level too deep
|
43
|
+
# https://github.com/jruby/jruby/issues/1265
|
44
|
+
if RUBY_PLATFORM == "java" and JRUBY_VERSION =~ /1\.7\.[5-8]/
|
45
|
+
methods.delete('all?')
|
46
|
+
end
|
47
|
+
|
48
|
+
methods.each do |enum_method|
|
49
|
+
if collection.respond_to?(enum_method)
|
50
|
+
tests("##{enum_method}").succeeds do
|
51
|
+
block_called = false
|
52
|
+
collection.send(enum_method) {|x| block_called = true }
|
53
|
+
block_called
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
[
|
59
|
+
'max_by','min_by'
|
60
|
+
].each do |enum_method|
|
61
|
+
if collection.respond_to?(enum_method)
|
62
|
+
tests("##{enum_method}").succeeds do
|
63
|
+
block_called = false
|
64
|
+
collection.send(enum_method) {|x| block_called = true; 0 }
|
65
|
+
block_called
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
if block_given?
|
74
|
+
yield(@instance)
|
75
|
+
end
|
76
|
+
|
77
|
+
if !Fog.mocking? || mocks_implemented
|
78
|
+
@instance.destroy
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
tests('failure') do
|
83
|
+
|
84
|
+
if !Fog.mocking? || mocks_implemented
|
85
|
+
@identity = @identity.to_s
|
86
|
+
@identity = @identity.gsub(/[a-zA-Z]/) { Fog::Mock.random_letters(1) }
|
87
|
+
@identity = @identity.gsub(/\d/) { Fog::Mock.random_numbers(1) }
|
88
|
+
@identity
|
89
|
+
end
|
90
|
+
|
91
|
+
tests("#get('#{@identity}')").returns(nil) do
|
92
|
+
pending if Fog.mocking? && !mocks_implemented
|
93
|
+
collection.get(@identity)
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
def flavors_tests(connection, params = {}, mocks_implemented = true)
|
2
|
+
tests('success') do
|
3
|
+
|
4
|
+
tests("#all").succeeds do
|
5
|
+
pending if Fog.mocking? && !mocks_implemented
|
6
|
+
connection.flavors.all
|
7
|
+
end
|
8
|
+
|
9
|
+
if !Fog.mocking? || mocks_implemented
|
10
|
+
@identity = connection.flavors.first.identity
|
11
|
+
end
|
12
|
+
|
13
|
+
tests("#get('#{@identity}')").succeeds do
|
14
|
+
pending if Fog.mocking? && !mocks_implemented
|
15
|
+
connection.flavors.get(@identity)
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
tests('failure') do
|
21
|
+
|
22
|
+
if !Fog.mocking? || mocks_implemented
|
23
|
+
invalid_flavor_identity = connection.flavors.first.identity.to_s.gsub(/\w/, '0')
|
24
|
+
end
|
25
|
+
|
26
|
+
tests("#get('#{invalid_flavor_identity}')").returns(nil) do
|
27
|
+
pending if Fog.mocking? && !mocks_implemented
|
28
|
+
connection.flavors.get(invalid_flavor_identity)
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
def server_tests(connection, params = {}, mocks_implemented = true)
|
2
|
+
model_tests(connection.servers, params, mocks_implemented) do
|
3
|
+
|
4
|
+
tests('#reload').returns(true) do
|
5
|
+
pending if Fog.mocking? && !mocks_implemented
|
6
|
+
@instance.wait_for { ready? }
|
7
|
+
identity = @instance.identity
|
8
|
+
!identity.nil? && identity == @instance.reload.identity
|
9
|
+
end
|
10
|
+
|
11
|
+
responds_to([:ready?, :state])
|
12
|
+
yield if block_given?
|
13
|
+
|
14
|
+
tests('#reboot').succeeds do
|
15
|
+
pending if Fog.mocking? && !mocks_implemented
|
16
|
+
@instance.wait_for { ready? }
|
17
|
+
@instance.reboot
|
18
|
+
end
|
19
|
+
|
20
|
+
if !Fog.mocking? || mocks_implemented
|
21
|
+
@instance.wait_for { ready? }
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
require "fog/schema/data_validator"
|
2
|
+
|
3
|
+
# format related hackery
|
4
|
+
# allows both true.is_a?(Fog::Boolean) and false.is_a?(Fog::Boolean)
|
5
|
+
# allows both nil.is_a?(Fog::Nullable::String) and ''.is_a?(Fog::Nullable::String)
|
6
|
+
module Fog
|
7
|
+
module Boolean; end
|
8
|
+
module Nullable
|
9
|
+
module Boolean; end
|
10
|
+
module Integer; end
|
11
|
+
module String; end
|
12
|
+
module Time; end
|
13
|
+
module Float; end
|
14
|
+
module Hash; end
|
15
|
+
module Array; end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
[FalseClass, TrueClass].each {|klass| klass.send(:include, Fog::Boolean)}
|
19
|
+
[FalseClass, TrueClass, NilClass, Fog::Boolean].each {|klass| klass.send(:include, Fog::Nullable::Boolean)}
|
20
|
+
[NilClass, String].each {|klass| klass.send(:include, Fog::Nullable::String)}
|
21
|
+
[NilClass, Time].each {|klass| klass.send(:include, Fog::Nullable::Time)}
|
22
|
+
[Integer, NilClass].each {|klass| klass.send(:include, Fog::Nullable::Integer)}
|
23
|
+
[Float, NilClass].each {|klass| klass.send(:include, Fog::Nullable::Float)}
|
24
|
+
[Hash, NilClass].each {|klass| klass.send(:include, Fog::Nullable::Hash)}
|
25
|
+
[Array, NilClass].each {|klass| klass.send(:include, Fog::Nullable::Array)}
|
26
|
+
|
27
|
+
module Shindo
|
28
|
+
class Tests
|
29
|
+
# Generates a Shindo test that compares a hash schema to the result
|
30
|
+
# of the passed in block returning true if they match.
|
31
|
+
#
|
32
|
+
# The schema that is passed in is a Hash or Array of hashes that
|
33
|
+
# have Classes in place of values. When checking the schema the
|
34
|
+
# value should match the Class.
|
35
|
+
#
|
36
|
+
# Strict mode will fail if the data has additional keys. Setting
|
37
|
+
# +strict+ to +false+ will allow additional keys to appear.
|
38
|
+
#
|
39
|
+
# @param [Hash] schema A Hash schema
|
40
|
+
# @param [Hash] options Options to change validation rules
|
41
|
+
# @option options [Boolean] :allow_extra_keys
|
42
|
+
# If +true+ does not fail when keys are in the data that are
|
43
|
+
# not specified in the schema. This allows new values to
|
44
|
+
# appear in API output without breaking the check.
|
45
|
+
# @option options [Boolean] :allow_optional_rules
|
46
|
+
# If +true+ does not fail if extra keys are in the schema
|
47
|
+
# that do not match the data. Not recommended!
|
48
|
+
# @yield Data to check with schema
|
49
|
+
#
|
50
|
+
# @example Using in a test
|
51
|
+
# Shindo.tests("comparing welcome data against schema") do
|
52
|
+
# data = {:welcome => "Hello" }
|
53
|
+
# data_matches_schema(:welcome => String) { data }
|
54
|
+
# end
|
55
|
+
#
|
56
|
+
# comparing welcome data against schema
|
57
|
+
# + data matches schema
|
58
|
+
#
|
59
|
+
# @example Example schema
|
60
|
+
# {
|
61
|
+
# "id" => String,
|
62
|
+
# "ram" => Integer,
|
63
|
+
# "disks" => [
|
64
|
+
# {
|
65
|
+
# "size" => Float
|
66
|
+
# }
|
67
|
+
# ],
|
68
|
+
# "dns_name" => Fog::Nullable::String,
|
69
|
+
# "active" => Fog::Boolean,
|
70
|
+
# "created" => DateTime
|
71
|
+
# }
|
72
|
+
#
|
73
|
+
# @return [Boolean]
|
74
|
+
def data_matches_schema(schema, options = {})
|
75
|
+
test('data matches schema') do
|
76
|
+
validator = Fog::Schema::DataValidator.new
|
77
|
+
valid = validator.validate(yield, schema, options)
|
78
|
+
@message = validator.message unless valid
|
79
|
+
valid
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
# @deprecated #formats is deprecated. Use #data_matches_schema instead
|
84
|
+
def formats(format, strict = true)
|
85
|
+
test('has proper format') do
|
86
|
+
if strict
|
87
|
+
options = {:allow_extra_keys => false, :allow_optional_rules => true}
|
88
|
+
else
|
89
|
+
options = {:allow_extra_keys => true, :allow_optional_rules => true}
|
90
|
+
end
|
91
|
+
validator = Fog::Schema::DataValidator.new
|
92
|
+
valid = validator.validate(yield, format, options)
|
93
|
+
@message = validator.message unless valid
|
94
|
+
valid
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
Shindo.tests('test_helper', 'meta') do
|
2
|
+
|
3
|
+
tests('comparing welcome data against schema') do
|
4
|
+
data = {:welcome => "Hello" }
|
5
|
+
data_matches_schema(:welcome => String) { data }
|
6
|
+
end
|
7
|
+
|
8
|
+
tests('#data_matches_schema') do
|
9
|
+
tests('when value matches schema expectation') do
|
10
|
+
data_matches_schema({"key" => String}) { {"key" => "Value"} }
|
11
|
+
end
|
12
|
+
|
13
|
+
tests('when values within an array all match schema expectation') do
|
14
|
+
data_matches_schema({"key" => [Integer]}) { {"key" => [1, 2]} }
|
15
|
+
end
|
16
|
+
|
17
|
+
tests('when nested values match schema expectation') do
|
18
|
+
data_matches_schema({"key" => {:nested_key => String}}) { {"key" => {:nested_key => "Value"}} }
|
19
|
+
end
|
20
|
+
|
21
|
+
tests('when collection of values all match schema expectation') do
|
22
|
+
data_matches_schema([{"key" => String}]) { [{"key" => "Value"}, {"key" => "Value"}] }
|
23
|
+
end
|
24
|
+
|
25
|
+
tests('when collection is empty although schema covers optional members') do
|
26
|
+
data_matches_schema([{"key" => String}], {:allow_optional_rules => true}) { [] }
|
27
|
+
end
|
28
|
+
|
29
|
+
tests('when additional keys are passed and not strict') do
|
30
|
+
data_matches_schema({"key" => String}, {:allow_extra_keys => true}) { {"key" => "Value", :extra => "Bonus"} }
|
31
|
+
end
|
32
|
+
|
33
|
+
tests('when value is nil and schema expects NilClass') do
|
34
|
+
data_matches_schema({"key" => NilClass}) { {"key" => nil} }
|
35
|
+
end
|
36
|
+
|
37
|
+
tests('when value and schema match as hashes') do
|
38
|
+
data_matches_schema({}) { {} }
|
39
|
+
end
|
40
|
+
|
41
|
+
tests('when value and schema match as arrays') do
|
42
|
+
data_matches_schema([]) { [] }
|
43
|
+
end
|
44
|
+
|
45
|
+
tests('when value is a Time') do
|
46
|
+
data_matches_schema({"time" => Time}) { {"time" => Time.now} }
|
47
|
+
end
|
48
|
+
|
49
|
+
tests('when key is missing but value should be NilClass (#1477)') do
|
50
|
+
data_matches_schema({"key" => NilClass}, {:allow_optional_rules => true}) { {} }
|
51
|
+
end
|
52
|
+
|
53
|
+
tests('when key is missing but value is nullable (#1477)') do
|
54
|
+
data_matches_schema({"key" => Fog::Nullable::String}, {:allow_optional_rules => true}) { {} }
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
tests('#formats backwards compatible changes') do
|
59
|
+
|
60
|
+
tests('when value matches schema expectation') do
|
61
|
+
formats({"key" => String}) { {"key" => "Value"} }
|
62
|
+
end
|
63
|
+
|
64
|
+
tests('when values within an array all match schema expectation') do
|
65
|
+
formats({"key" => [Integer]}) { {"key" => [1, 2]} }
|
66
|
+
end
|
67
|
+
|
68
|
+
tests('when nested values match schema expectation') do
|
69
|
+
formats({"key" => {:nested_key => String}}) { {"key" => {:nested_key => "Value"}} }
|
70
|
+
end
|
71
|
+
|
72
|
+
tests('when collection of values all match schema expectation') do
|
73
|
+
formats([{"key" => String}]) { [{"key" => "Value"}, {"key" => "Value"}] }
|
74
|
+
end
|
75
|
+
|
76
|
+
tests('when collection is empty although schema covers optional members') do
|
77
|
+
formats([{"key" => String}]) { [] }
|
78
|
+
end
|
79
|
+
|
80
|
+
tests('when additional keys are passed and not strict') do
|
81
|
+
formats({"key" => String}, false) { {"key" => "Value", :extra => "Bonus"} }
|
82
|
+
end
|
83
|
+
|
84
|
+
tests('when value is nil and schema expects NilClass') do
|
85
|
+
formats({"key" => NilClass}) { {"key" => nil} }
|
86
|
+
end
|
87
|
+
|
88
|
+
tests('when value and schema match as hashes') do
|
89
|
+
formats({}) { {} }
|
90
|
+
end
|
91
|
+
|
92
|
+
tests('when value and schema match as arrays') do
|
93
|
+
formats([]) { [] }
|
94
|
+
end
|
95
|
+
|
96
|
+
tests('when value is a Time') do
|
97
|
+
formats({"time" => Time}) { {"time" => Time.now} }
|
98
|
+
end
|
99
|
+
|
100
|
+
tests('when key is missing but value should be NilClass (#1477)') do
|
101
|
+
formats({"key" => NilClass}) { {} }
|
102
|
+
end
|
103
|
+
|
104
|
+
tests('when key is missing but value is nullable (#1477)') do
|
105
|
+
formats({"key" => Fog::Nullable::String}) { {} }
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|