Skip to content

Commit

Permalink
remove useless calls to with_mocked_nodes context
Browse files Browse the repository at this point in the history
  • Loading branch information
rrotter committed Dec 13, 2024
1 parent 7144e4b commit bcd883d
Show file tree
Hide file tree
Showing 8 changed files with 0 additions and 45 deletions.
1 change: 0 additions & 1 deletion spec/classes/all_roles_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# All Rights Reserved. Licensed according to the terms of the Revised
# BSD License. See LICENSE.txt for details.
require 'spec_helper'
require_relative '../support/contexts/with_mocked_nodes'

def puppet_role_name_from(path)
path.strip.gsub('/', '::').gsub(%r{^manifests}, 'nebula').gsub(%r{\.pp}, '')
Expand Down
3 changes: 0 additions & 3 deletions spec/classes/profile/http_fileserver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@
# All Rights Reserved. Licensed according to the terms of the Revised
# BSD License. See LICENSE.txt for details.
require 'spec_helper'
require_relative '../../support/contexts/with_mocked_nodes'

describe 'nebula::profile::http_fileserver' do
on_supported_os.each do |os, os_facts|
context "on #{os}" do
include_context 'with mocked query for nodes in other datacenters'

let(:facts) { os_facts }
let(:hiera_config) { 'spec/fixtures/hiera/deb_server_config.yaml' }
let(:node) { 'foo.example.com' } # see spec/default_facts.yml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,23 @@
# All Rights Reserved. Licensed according to the terms of the Revised
# BSD License. See LICENSE.txt for details.
require 'spec_helper'
require_relative '../../../../support/contexts/with_mocked_nodes'

describe 'nebula::profile::networking::firewall::http_datacenters' do
on_supported_os.each do |os, os_facts|
context "on #{os}" do
let(:facts) { os_facts }

include_context 'with mocked query for nodes in other datacenters'

it { is_expected.to compile }

it { is_expected.to have_firewall_resource_count(0) }

context 'with a CIDR range' do
include_context 'with mocked query for nodes in other datacenters', ['somedc'], []

let(:params) { { networks: [{ 'name' => 'somedc', 'block' => '10.1.2.0/24', 'datacenter' => 'somedc' }] } }

it { is_expected.to contain_firewall('200 HTTP: somedc').with_source('10.1.2.0/24') }
end

context 'with deeply-nested ranges and nodes in other datacenters' do
othernodes = { 'node1' => '10.3.4.5', 'node2' => '10.4.5.6' }

include_context 'with mocked query for nodes in other datacenters', %w[dc1 dc2], othernodes

let(:params) do
{
networks: [
Expand Down
3 changes: 0 additions & 3 deletions spec/classes/role/chipmunk_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@
# All Rights Reserved. Licensed according to the terms of the Revised
# BSD License. See LICENSE.txt for details.
require 'spec_helper'
require_relative '../../support/contexts/with_mocked_nodes'

describe 'nebula::role::chipmunk' do
on_supported_os.each do |os, os_facts|
context "on #{os}" do
include_context 'with mocked query for nodes in other datacenters'

let(:facts) { os_facts }
let(:hiera_config) { 'spec/fixtures/hiera/chipmunk_config.yaml' }

Expand Down
3 changes: 0 additions & 3 deletions spec/classes/role/deb_server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@
# BSD License. See LICENSE.txt for details.
require 'spec_helper'
require 'faker'
require_relative '../../support/contexts/with_mocked_nodes'

describe 'nebula::role::deb_server' do
on_supported_os.each do |os, os_facts|
context "on #{os}" do
include_context 'with mocked query for nodes in other datacenters'

let(:facts) { os_facts.deep_merge(networking: { ip: Faker::Internet.ip_v4_address, interfaces: {} }) }
let(:hiera_config) { 'spec/fixtures/hiera/deb_server_config.yaml' }

Expand Down
3 changes: 0 additions & 3 deletions spec/classes/role/fulcrum_app_host_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@
# All Rights Reserved. Licensed according to the terms of the Revised
# BSD License. See LICENSE.txt for details.
require 'spec_helper'
require_relative '../../support/contexts/with_mocked_nodes'

describe 'nebula::role::fulcrum::app_host' do
on_supported_os.each do |os, os_facts|
context "on #{os}" do
let(:facts) { os_facts }
let(:hiera_config) { 'spec/fixtures/hiera/fulcrum_config.yaml' }

include_context 'with mocked query for nodes in other datacenters', %w[one two], []

it { is_expected.to compile }
end
end
Expand Down
3 changes: 0 additions & 3 deletions spec/classes/role/fulcrum_standalone_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@
# All Rights Reserved. Licensed according to the terms of the Revised
# BSD License. See LICENSE.txt for details.
require 'spec_helper'
require_relative '../../support/contexts/with_mocked_nodes'

describe 'nebula::role::fulcrum::standalone' do
on_supported_os.each do |os, os_facts|
context "on #{os}" do
let(:facts) { os_facts }
let(:hiera_config) { 'spec/fixtures/hiera/fulcrum_config.yaml' }

include_context 'with mocked query for nodes in other datacenters', %w[one two], []

it { is_expected.to compile }
end
end
Expand Down
20 changes: 0 additions & 20 deletions spec/support/contexts/with_mocked_nodes.rb
Original file line number Diff line number Diff line change
@@ -1,25 +1,5 @@
# frozen_string_literal: true

RSpec.shared_context 'with mocked query for nodes in other datacenters' do |datacenters = [], nodes = []|
let!(:puppetdb_query) do
MockFunction.new('puppetdb_query') do |f|
f.stubbed
.with(['from', 'facts',
['extract', %w[certname value],
['and',
['=', 'name', 'ipaddress'],
['in', 'certname',
['extract', ['certname'],
['select_facts',
['and',
['=', 'name', 'datacenter'],
['not', ['in', 'value',
['array', datacenters]]]]]]]]]])
.returns(nodes.map { |name, ip| { 'certname' => name, 'value' => ip } })
end
end
end

RSpec.shared_context 'with mocked puppetdb functions' do |_datacenter, nodes, class_nodes|
before(:each) do
stub_loader!
Expand Down

0 comments on commit bcd883d

Please sign in to comment.