aboutsummaryrefslogtreecommitdiffstats
path: root/spec/unit/type/sriov_vf_config_spec.rb
blob: 9a911f604bb051692d2382d2a4def3ff48c1eb5a (plain)
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
require 'puppet'
require 'puppet/type/sriov_vf_config'

describe 'Puppet::Type.type(:sriov_vf_config)' do
  it 'should allow name to be passed' do
    expect{Puppet::Type.type(:sriov_vf_config).new(
      :name   => 'eth0:10',
      :ensure => 'present'
    )}.not_to raise_error
  end
  it 'should allow name to be passed with -' do
    expect{Puppet::Type.type(:sriov_vf_config).new(
      :name   => 'eth-0:10',
      :ensure => 'present'
    )}.not_to raise_error
  end
  it 'should allow name to be passed with _' do
    expect{Puppet::Type.type(:sriov_vf_config).new(
      :name   => 'eth_0:10',
      :ensure => 'present'
    )}.not_to raise_error
  end
  it 'should throw error for invalid format' do
    expect{Puppet::Type.type(:sriov_vf_config).new(
      :name   => 'eth0',
      :ensure => 'present'
    )}.to raise_error(Puppet::ResourceError)
  end
  it 'should throw error for invalid format without interface name' do
    expect{Puppet::Type.type(:sriov_vf_config).new(
      :name   => ':9',
      :ensure => 'present'
    )}.to raise_error(Puppet::ResourceError)
  end
  it 'should throw error for invalid format for numvfs' do
    expect{Puppet::Type.type(:sriov_vf_config).new(
      :name   => 'eth8:none',
      :ensure => 'present'
    )}.to raise_error(Puppet::ResourceError)
  end
  it 'should throw error for invalid format without numvfs' do
    expect{Puppet::Type.type(:sriov_vf_config).new(
      :name   => 'eth0:',
      :ensure => 'present'
    )}.to raise_error(Puppet::ResourceError)
  end
end