Sha256: 789f46916c1d2a6646eba8f342a41520f4186f3d7afa045df8382f3449e2ab0a

Contents?: true

Size: 1.84 KB

Versions: 17

Compression:

Stored size: 1.84 KB

Contents

# frozen_string_literal: true

# Copyright 2018 Tristan Robert

# This file is part of ForemanFogProxmox.

# ForemanFogProxmox is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# ForemanFogProxmox is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>.

require 'test_plugin_helper'
require 'active_support/core_ext/hash/indifferent_access'

module ForemanFogProxmox
  class ProxmoxVmCommandsServerTest < ActiveSupport::TestCase
    include ComputeResourceTestHelpers

    describe 'clone_from_image' do
      before do
        @cr = FactoryBot.build_stubbed(:proxmox_cr)
        @args = { :name => 'name' }
        @image_id = 100
        @vmid = 101
        @image = mock('vm')
        @image.expects(:clone)
        @cr.stubs(:find_vm_by_uuid).with(@image_id).returns(@image)
        @clone = mock('vm')
      end
      it 'clones server from image' do
        @clone.expects(:update).with(:name => 'name')
        @clone.stubs(:container?).returns(false)
        @cr.stubs(:find_vm_by_uuid).with(@vmid).returns(@clone)
        @cr.clone_from_image(@image_id, @args, @vmid)
      end
      it 'clones container from image' do
        @clone.stubs(:container?).returns(true)
        @clone.expects(:update).with(:hostname => 'name')
        @cr.stubs(:find_vm_by_uuid).with(@vmid).returns(@clone)
        @cr.clone_from_image(@image_id, @args, @vmid)
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
foreman_fog_proxmox-0.13.3 test/unit/foreman_fog_proxmox/proxmox_images_test.rb
foreman_fog_proxmox-0.13.2 test/unit/foreman_fog_proxmox/proxmox_images_test.rb
foreman_fog_proxmox-0.13.1 test/unit/foreman_fog_proxmox/proxmox_images_test.rb
foreman_fog_proxmox-0.13.0 test/unit/foreman_fog_proxmox/proxmox_images_test.rb
foreman_fog_proxmox-0.12.4 test/unit/foreman_fog_proxmox/proxmox_images_test.rb
foreman_fog_proxmox-0.12.2 test/unit/foreman_fog_proxmox/proxmox_images_test.rb
foreman_fog_proxmox-0.12.1 test/unit/foreman_fog_proxmox/proxmox_images_test.rb
foreman_fog_proxmox-0.12.0 test/unit/foreman_fog_proxmox/proxmox_images_test.rb
foreman_fog_proxmox-0.11.1 test/unit/foreman_fog_proxmox/proxmox_images_test.rb
foreman_fog_proxmox-0.11.0 test/unit/foreman_fog_proxmox/proxmox_images_test.rb
foreman_fog_proxmox-0.10.2 test/unit/foreman_fog_proxmox/proxmox_images_test.rb
foreman_fog_proxmox-0.10.1 test/unit/foreman_fog_proxmox/proxmox_images_test.rb
foreman_fog_proxmox-0.10.0 test/unit/foreman_fog_proxmox/proxmox_images_test.rb
foreman_fog_proxmox-0.9.4 test/unit/foreman_fog_proxmox/proxmox_images_test.rb
foreman_fog_proxmox-0.9.3 test/unit/foreman_fog_proxmox/proxmox_images_test.rb
foreman_fog_proxmox-0.9.2 test/unit/foreman_fog_proxmox/proxmox_images_test.rb
foreman_fog_proxmox-0.9.1 test/unit/foreman_fog_proxmox/proxmox_images_test.rb