<commit_before>require 'spec_helper'
require 'guignol/models/instance'

describe Guignol::Models::Instance do
  subject { described_class.new(name, options) }

  let(:name) { "foobar" }
  let(:options) {{
    :uuid => '948DB8E9-A356-4F66-8857-165FBDF5A71F'
  }}

  before(:each) do
    # connection = stub(:servers => [])
    # Fog::Compute.stub(:new).and_return(connection)
  end

  describe '#initialize' do
    it 'should require :uuid' do
      options.delete :uuid
      expect { subject }.to raise_error
    end

    it 'should require a name' do
      name.replace ""
      expect { subject }.to raise_error
    end

    it 'should pass with minimal options' do
      expect { subject }.to_not raise_error
    end

    it 'parses ERB in user data' do
      options[:foo] = 'bar'
      options[:user_data] = "foo=<%= foo %>,<%= name %>"
      subject.options[:user_data].should == 'foo=bar,foobar'
    end
  end


  shared_examples_for 'server setup' do
    it 'set server tags'
    it 'configures DNS properly'
  end


  describe '#create' do
    it 'should pass with minimal options' do
      subject.create
    end

    it 'does not break when providing an availibity zone' do
      instance = described_class.new(name, options.merge(:availability_zone => 'eu-west-1c'))
      expect { instance.create }.to_not raise_error
    end

    it 'does not allow an availability zone that does not match the region' do
      instance = described_class.new(name, options.merge(:availability_zone => 'us-west-1a'))
      expect { instance.create }.to raise_error('availability zone us-west-1a is not in the defined region eu-west-1')
    end

    it 'requires existing volumes to live in a given availability zone'
    it 'reuses existing volumes'<commit_msg>add an assertion to a test that could potentially return a false positive.<commit_after>require 'spec_helper'
require 'guignol/models/instance'

describe Guignol::Models::Instance do
  subject { described_class.new(name, options) }

  let(:name) { "foobar" }
  let(:options) {{
    :uuid => '948DB8E9-A356-4F66-8857-165FBDF5A71F'
  }}

  before(:each) do
    # connection = stub(:servers => [])
    # Fog::Compute.stub(:new).and_return(connection)
  end

  describe '#initialize' do
    it 'should require :uuid' do
      options.delete :uuid
      expect { subject }.to raise_error
    end

    it 'should require a name' do
      name.replace ""
      expect { subject }.to raise_error
    end

    it 'should pass with minimal options' do
      expect { subject }.to_not raise_error
    end

    it 'parses ERB in user data' do
      options[:foo] = 'bar'
      options[:user_data] = "foo=<%= foo %>,<%= name %>"
      subject.options[:user_data].should == 'foo=bar,foobar'
    end
  end


  shared_examples_for 'server setup' do
    it 'set server tags'
    it 'configures DNS properly'
  end


  describe '#create' do
    it 'should pass with minimal options' do
      expect { subject.create }.to_not raise_error
    end

    it 'does not break when providing an availibity zone' do
      instance = described_class.new(name, options.merge(:availability_zone => 'eu-west-1c'))
      expect { instance.create }.to_not raise_error
    end

    it 'does not allow an availability zone that does not match the region' do
      instance = described_class.new(name, options.merge(:availability_zone => 'us-west-1a'))
      expect { instance.create }.to raise_error('availability zone us-west-1a is not in the defined region eu-west-1')
    end

    it 'requires existing volumes to live in a given availability zone'
    it 'reuses existing volumes'
{'fraction_non_alphanumeric': 0.10701413917382867, 'fraction_numerical': 0.01386193512614361, 'mean_word_length': 3.151898734177215, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, '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': '5369901', 'n_tokens_mistral': 1164, 'n_tokens_neox': 1102, 'n_words': 350}