File: cache_data_spec.rb

package info (click to toggle)
puppet-module-extlib 7.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 420 kB
  • sloc: ruby: 1,035; sh: 15; makefile: 10
file content (30 lines) | stat: -rw-r--r-- 1,074 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
# frozen_string_literal: true

require 'spec_helper'

describe 'extlib::cache_data' do
  let(:initial_data) { 'original_password' }
  let(:data_name) { 'mysql_password' }
  let(:namespace) { 'data_cache' }

  it { expect(subject).not_to eq(nil) }
  it { is_expected.not_to eq(nil) }
  it { is_expected.to run.with_params(data_name).and_raise_error(ArgumentError) }
  it { is_expected.to run.with_params('', initial_data).and_raise_error(ArgumentError) }
  it { is_expected.to run.with_params('', 'mysql_password', initial_data).and_raise_error(ArgumentError) }

  describe 'data caching' do
    context 'when not in cache' do
      it 'returns supplied data' do
        is_expected.to run.with_params(namespace, data_name, initial_data).and_return(initial_data)
      end
    end

    context 'when cached' do
      it 'returns cached data' do
        is_expected.to run.with_params(namespace, data_name, initial_data).and_return(initial_data)
        is_expected.to run.with_params(namespace, data_name, 'new_password').and_return(initial_data)
      end
    end
  end
end