File: plugin_spec.rb

package info (click to toggle)
vagrant-libvirt 0.12.2-4
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 1,756 kB
  • sloc: ruby: 12,865; xml: 2,465; sh: 373; javascript: 235; makefile: 13
file content (46 lines) | stat: -rw-r--r-- 1,460 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# frozen_string_literal: true

require_relative '../spec_helper'

require 'vagrant-libvirt'
require 'vagrant-libvirt/plugin'
require 'vagrant-libvirt/action'
require 'vagrant-libvirt/action/remove_libvirt_image'


describe VagrantPlugins::ProviderLibvirt::Plugin do
  subject { described_class.new }

  include_context 'unit'

  describe '#action_hook remove_libvirt_image' do
    before do
      # set up some dummy boxes
      box_path = File.join(env[:env].boxes.directory, 'vagrant-libvirt-VAGRANTSLASH-test', '0.0.1')
      ['libvirt', 'virtualbox'].each do |provider|
        provider_path = File.join(box_path, provider)
        FileUtils.mkdir_p(provider_path)
        metadata = {'provider': provider}
        File.open(File.join(provider_path, 'metadata.json'), "w") { |f| f.write metadata.to_json }
      end
    end

    it 'should call the action hook after box remove' do
      expect_any_instance_of(VagrantPlugins::ProviderLibvirt::Action::RemoveLibvirtImage).to receive(:call) do |cls, env|
        cls.instance_variable_get(:@app).call(env)
      end
      expect {
        env[:env].action_runner.run(
          Vagrant::Action.action_box_remove, {
            box_name: 'vagrant-libvirt/test',
            box_provider: 'libvirt',
            box_version: '0.0.1',
            force_confirm_box_remove: true,
            box_remove_all_versions: false,
            ui: ui,
          }
        )
      }.to_not raise_error
    end
  end
end