File: nfs_test.rb

package info (click to toggle)
vagrant 2.3.7%2Bgit20230731.5fc64cde%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 17,616 kB
  • sloc: ruby: 111,820; sh: 462; makefile: 123; ansic: 34; lisp: 1
file content (62 lines) | stat: -rw-r--r-- 1,707 bytes parent folder | download | duplicates (4)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
require_relative "../../../../base"
require_relative "../../../../../../plugins/hosts/void/cap/nfs"
require "vagrant/util"

describe VagrantPlugins::HostVoid::Cap::NFS do

  include_context "unit"

  let(:caps) do
    VagrantPlugins::HostVoid::Plugin
      .components
      .host_capabilities[:void]
  end

  let(:env) { double("env") }

  context ".nfs_check_command" do
    it "should provide nfs_check_command capability" do
      expect(caps.get(:nfs_check_command)).to eq(described_class)
    end

    it "should return command to execute" do
      expect(caps.get(:nfs_check_command).nfs_check_command(env)).to be_a(String)
    end
  end

  context ".nfs_start_command" do
    it "should provide nfs_start_command capability" do
      expect(caps.get(:nfs_start_command)).to eq(described_class)
    end

    it "should return command to execute" do
      expect(caps.get(:nfs_start_command).nfs_start_command(env)).to be_a(String)
    end
  end

  context ".nfs_installed" do
    let(:exit_code) { 0 }
    let(:result) { Vagrant::Util::Subprocess::Result.new(exit_code, "", "") }

    before { allow(Vagrant::Util::Subprocess).to receive(:execute).
        with("/usr/bin/xbps-query", "nfs-utils").and_return(result) }

    it "should provide nfs_installed capability" do
      expect(caps.get(:nfs_installed)).to eq(described_class)
    end

    context "when installed" do
      it "should return true" do
        expect(caps.get(:nfs_installed).nfs_installed(env)).to be_truthy
      end
    end

    context "when not installed" do
      let(:exit_code) { 1 }

      it "should return false" do
        expect(caps.get(:nfs_installed).nfs_installed(env)).to be_falsey
      end
    end
  end
end