File: ruby_spec.rb

package info (click to toggle)
puppet-module-voxpupuli-elasticsearch 9.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,496 kB
  • sloc: ruby: 9,906; sh: 392; makefile: 4
file content (61 lines) | stat: -rw-r--r-- 1,366 bytes parent folder | download
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
# frozen_string_literal: true

require 'spec_helper_rspec'

describe Puppet::Type.type(:elasticsearch_role).provider(:ruby) do
  describe 'instances' do
    it 'has an instance method' do
      expect(described_class).to respond_to :instances
    end

    context 'with no roles' do
      it 'returns no resources' do
        expect(described_class.parse("\n")).to eq([])
      end
    end

    context 'with one role' do
      it 'returns one resource' do
        expect(described_class.parse(%(
          admin:
            cluster: all
            indices:
              '*': all
        ))[0]).to eq(
          ensure: :present,
          name: 'admin',
          privileges: {
            'cluster' => 'all',
            'indices' => {
              '*' => 'all'
            }
          }
        )
      end
    end

    context 'with multiple roles' do
      it 'returns three resources' do
        expect(described_class.parse(%(
          admin:
            cluster: all
            indices:
              '*': all
          user:
            indices:
                '*': read
          power_user:
            cluster: monitor
            indices:
              '*': all
        )).length).to eq(3)
      end
    end
  end

  describe 'prefetch' do
    it 'has a prefetch method' do
      expect(described_class).to respond_to :prefetch
    end
  end
end