<commit_before>require_relative "../../aws_helper"

describe ManageIQ::Providers::Amazon::StorageManager::Ebs::CloudVolume do
  let(:ems_cloud) { FactoryBot.create(:ems_amazon_with_authentication) }
  let(:ebs) { FactoryBot.create(:ems_amazon_ebs, :parent_ems_id => ems_cloud.id) }
  let(:availability_zone) { FactoryBot.create(:availability_zone_amazon) }
  let(:cloud_volume) { FactoryBot.create(:cloud_volume_amazon_gp2, :ext_management_system => ebs, :ems_ref => "vol_1", :availability_zone => availability_zone) }

  describe "cloud volume operations" do
    context ".raw_create_volume" do
      it "creates a volume" do
        stubbed_responses = {
          :ec2 => {
            :create_volume => {
              :volume_id         => "volume_id",
              :size              => 1,
              :availability_zone => "az1",
              :state             => "creating",
              :volume_type       => "gp2"
            },
            :create_tags   => {}
          }
        }

        options = {
          :name              => "volume",
          :availability_zone => "az1",
          :size              => 1,
          :volume_type       => "gp2",
        }

        with_aws_stubbed(stubbed_responses) do
          expect(CloudVolume.create_volume(ebs, options)).to be_truthy
        end
      end
    end

    context "#update_volume" do
      let(:update_volume_name_stub) { { :create_tags => {}, :modify_volume => "failed" } }
      let(:modify_volume_stub) { { :create_tags => "failed", :modify_volume => {} } }
      let(:full_update_volume_stub) { { :create_tags => {}, :modify_volume => {} } }

      context "updating volume name" do<commit_msg>Pass id to AR::Base find, not AR::Base objs<commit_after>require_relative "../../aws_helper"

describe ManageIQ::Providers::Amazon::StorageManager::Ebs::CloudVolume do
  let(:ems_cloud) { FactoryBot.create(:ems_amazon_with_authentication) }
  let(:ebs) { FactoryBot.create(:ems_amazon_ebs, :parent_ems_id => ems_cloud.id) }
  let(:availability_zone) { FactoryBot.create(:availability_zone_amazon) }
  let(:cloud_volume) { FactoryBot.create(:cloud_volume_amazon_gp2, :ext_management_system => ebs, :ems_ref => "vol_1", :availability_zone => availability_zone) }

  describe "cloud volume operations" do
    context ".raw_create_volume" do
      it "creates a volume" do
        stubbed_responses = {
          :ec2 => {
            :create_volume => {
              :volume_id         => "volume_id",
              :size              => 1,
              :availability_zone => "az1",
              :state             => "creating",
              :volume_type       => "gp2"
            },
            :create_tags   => {}
          }
        }

        options = {
          :name              => "volume",
          :availability_zone => "az1",
          :size              => 1,
          :volume_type       => "gp2",
        }

        with_aws_stubbed(stubbed_responses) do
          expect(CloudVolume.create_volume(ebs.id, options)).to be_truthy
        end
      end
    end

    context "#update_volume" do
      let(:update_volume_name_stub) { { :create_tags => {}, :modify_volume => "failed" } }
      let(:modify_volume_stub) { { :create_tags => "failed", :modify_volume => {} } }
      let(:full_update_volume_stub) { { :create_tags => {}, :modify_volume => {} } }

      context "updating volume name" do
{'fraction_non_alphanumeric': 0.13246982631733883, 'fraction_numerical': 0.005298793052693553, 'mean_word_length': 2.2704523580365734, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5110068', 'n_tokens_mistral': 1046, 'n_tokens_neox': 1029, 'n_words': 174}