spec/opsicle/cloneable_instance_spec.rb in opsicle-2.6.0 vs spec/opsicle/cloneable_instance_spec.rb in opsicle-2.8.0
- old
+ new
@@ -12,11 +12,11 @@
:layer_ids => [12345, 67890], :auto_scaling_type => 'auto_scaling_type',
:os => 'os', :ssh_key_name => 'ssh_key_name',
:availability_zone => 'availability_zone', :virtualization_type => 'virtualization_type',
:subnet_id => 'subnet_id', :architecture => 'architecture',
:root_device_type => 'root_device_type', :install_updates_on_boot => 'install_updates_on_boot',
- :ebs_optimized => 'ebs_optimized', :tenancy => 'tenancy')
+ :ebs_optimized => 'ebs_optimized', :tenancy => 'tenancy', :instance_id => 'some-id')
@layer = double('layer1', :name => 'layer-1', :layer_id => 12345, :instances => [@instance], :ami_id => nil, :agent_version => nil)
allow(@layer).to receive(:ami_id=)
allow(@layer).to receive(:ami_id)
allow(@layer).to receive(:agent_version=)
allow(@layer).to receive(:agent_version)
@@ -36,34 +36,33 @@
end
context "#make_new_hostname" do
it "should make a unique incremented hostname" do
instance = CloneableInstance.new(@instance, @layer, @opsworks, @cli)
- expect(instance).to receive(:increment_hostname).and_return('example-hostname-03')
instance1 = double('instance', :hostname => 'example-hostname-01')
instance2 = double('instance', :hostname => 'example-hostname-02')
allow(@layer).to receive(:instances).and_return([instance1, instance2])
- instance.make_new_hostname('example-hostname-01')
+ expect(instance.make_new_hostname).to eq('example-hostname-03')
end
it "should make a unique incremented hostname" do
instance = CloneableInstance.new(@instance, @layer, @opsworks, @cli)
instance1 = double('instance', :hostname => 'example-hostname-01')
instance2 = double('instance', :hostname => 'example-hostname-02')
instance3 = double('instance', :hostname => 'example-hostname-03')
instance4 = double('instance', :hostname => 'example-hostname-04')
- expect(@layer).to receive(:instances).and_return([instance1, instance2, instance3, instance4])
- expect(instance.make_new_hostname('example-hostname-01')).to eq('example-hostname-05')
+ allow(@layer).to receive(:instances).and_return([instance1, instance2, instance3, instance4])
+ expect(instance.make_new_hostname).to eq('example-hostname-05')
end
end
context "#increment_hostname" do
it "should increment the hostname" do
instance = CloneableInstance.new(@instance, @layer, @opsworks, @cli)
expect(instance).to receive(:hostname_unique?).and_return('example-hostname-03')
allow(@opsworks).to receive(:describe_agent_version).with({})
- instance.increment_hostname('example-hostname-01', ['example-hostname-01', 'example-hostname-02'])
+ expect(instance.increment_hostname).to eq('example-hostname-01')
end
end
context "#clone" do
it "should grab instances and make new hostname" do
@@ -82,9 +81,16 @@
end
it "should create new instance" do
instance = CloneableInstance.new(@instance, @layer, @opsworks, @cli)
expect(instance).to receive(:create_new_instance)
+ instance.clone({})
+ end
+
+ it "should start new instance" do
+ instance = CloneableInstance.new(@instance, @layer, @opsworks, @cli)
+ allow(instance).to receive(:ask_to_start_instance).and_return(true)
+ expect(instance).to receive(:start_new_instance)
instance.clone({})
end
end
context '#verify_agent_version' do