diff --git a/README.md b/README.md index 60808dfa0..9e4327758 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ * [Configuration](#configuration) * [Naming conventions](#naming-conventions) * [Example groups](#example-groups) -* [Defined Types, Classes & Applications](#defined-types-classes--applications) +* [Defined Types and Classes](#defined-types-and-classes) * [Functions](#functions) * [Hiera integration](#hiera-integration) * [Producing coverage reports](#producing-coverage-reports) @@ -259,9 +259,6 @@ structure and naming convention. ├── defines/ │ └── _spec.rb │ - ├── applications/ - │ └── _spec.rb - │ ├── functions/ │ └── _spec.rb │ @@ -289,10 +286,6 @@ describe 'mydefine', :type => :define do ... end -describe 'myapplication', :type => :application do - ... -end - describe 'myfunction', :type => :puppet_function do ... end @@ -310,7 +303,7 @@ describe 'myhost.example.com', :type => :host do end ``` -## Defined Types, Classes & Applications +## Defined Types and Classes ### Matchers @@ -601,7 +594,7 @@ let(:title) { 'foo' } #### Specifying the parameters to pass to a resources or parameterised class -Parameters of a defined type, class or application can be passed defining `:params` in a let, +Parameters of a defined type or class can be passed defining `:params` in a let, and passing it a hash as seen below. ```ruby @@ -621,7 +614,7 @@ let(:params) { {'password' =>sensitive('secret') } } ``` For references to nodes or resources as seen when using `require` or `before` properties, -or an `application` resource you can pass the string as an argument to the `ref` helper: +you can pass the string as an argument to the `ref` helper: ```ruby let(:params) { 'require' => ref('Package', 'sudoku') } @@ -633,18 +626,6 @@ Which translates to: mydefine { 'mytitle': require => Package['sudoku'] } ``` -Another example, for an application setup (when using `app_management`): - -```ruby -let(:params) { { 'nodes' => { ref('Node', 'dbnode') => ref('Myapp::Mycomponent', 'myapp') } } } -``` - -Will translate to: - -```puppet -site { myapp { 'myimpl': nodes => { Node['dbnode'] => Myapp::Mycomponent['myimpl'] } } } -``` - #### Specifying the FQDN of the test node If the manifest you're testing expects to run on host with a particular name, @@ -835,46 +816,6 @@ You can also use `exported_resources` directly in a test: it { expect(exported_resources).to contain_file('foo') } ``` -#### Testing applications - -Applications in some ways behave as defined resources, but are more complex so -require a number of elements already documented above to be combined for testing. - -A full example of the simplest rspec test for a single component application: - -```ruby -require 'spec_helper' - -describe 'orch_app' do - let(:node) { 'my_node' } - let(:title) { 'my_awesome_app' } - let(:params) do - { - 'nodes' => { - ref('Node', node) => ref('Orch_app::Db', title), - } - } - end - - it { should compile } - it { should contain_orch_app(title) } -end -``` - -Each piece is required: - -* You must turn on app_management during testing for the handling to work -* The `:node` definition is required to be set so later on you can reference it in the `:nodes` argument within `:params` -* Applications act like defined resources, and each require a `:title` to be defined -* The `:nodes` key in `:params` requires the use of node reference mappings to resource - mappings. The `ref` keyword allows you to provide these (a normal string will not work). - -Beyond these requirements, the very basic `should compile` test and other matchers -as you would expect will work the same as classes and defined resources. - -**Note:** for the moment, cross-node support is not available and will return an error. -Ensure you model your tests to be single-node for the time being. - ## Functions ### Matchers diff --git a/Rakefile b/Rakefile index cebb94086..5c4813194 100644 --- a/Rakefile +++ b/Rakefile @@ -32,7 +32,7 @@ namespace :test do if t.respond_to?(:exclude_pattern) t.exclude_pattern = 'spec/fixtures/**/*_spec.rb' else - t.pattern = 'spec/{applications,classes,defines,functions,hosts,type_aliases,types,unit}/**/*_spec.rb' + t.pattern = 'spec/{classes,defines,functions,hosts,type_aliases,types,unit}/**/*_spec.rb' end end diff --git a/docs/documentation/applications/index.md b/docs/documentation/applications/index.md deleted file mode 100644 index eb12374f2..000000000 --- a/docs/documentation/applications/index.md +++ /dev/null @@ -1,62 +0,0 @@ ---- -layout: base -title: Testing Applications -icon: fa fa-cubes -breadcrumbs: - - - name: Documentation - path: /documentation/ ---- - -
-
-
-Application management is only available on Puppet >= 4.3.0 -
-
- -## Basic Test Structure - -{% highlight ruby %} -describe '' do - let(:node) { '' } - let(:title) { '' } - let(:params) do - { - 'nodes' => { - ref('Node', node) => ref('', title), - } - # any additional app parameters - } - end - - # tests go here -end -{% endhighlight %} - - * The `node` definition is required to be set so that it can be later - referenced in the `nodes` parameter. - * Applications act like defined types and require a `title` to be defined. - * The `nodes` parameter requires the use of node reference mappings to - resource mappings. The `ref` method creates these references (a normal - string will not suffice). - -
-
-
-Cross-node support is not available at the moment and will return an error. -Ensure that you model your tests to be single-node. -
-
- -## Configuring The Tests - -{% include non_host_inputs.md %} - -{% include common_inputs.md %} - -{% include facts_inputs.md %} - -## Testing The Catalogue - -{% include catalogue_matchers.md %} diff --git a/docs/documentation/index.md b/docs/documentation/index.md index 6cd8fb0a1..706266cab 100644 --- a/docs/documentation/index.md +++ b/docs/documentation/index.md @@ -39,12 +39,6 @@ cards: path: /documentation/hosts/ icon: fa fa-server colour: orange - - - title: Testing Applications - text: - path: /documentation/applications/ - icon: fa fa-cubes - colour: green - title: Testing Types text: diff --git a/lib/rspec-puppet/example.rb b/lib/rspec-puppet/example.rb index 2f59c887e..2bed2ca70 100644 --- a/lib/rspec-puppet/example.rb +++ b/lib/rspec-puppet/example.rb @@ -8,7 +8,6 @@ require 'rspec-puppet/example/type_example_group' require 'rspec-puppet/example/type_alias_example_group' require 'rspec-puppet/example/provider_example_group' -require 'rspec-puppet/example/application_example_group' RSpec.configure do |c| def c.rspec_puppet_include(group, type, file_path) @@ -25,7 +24,6 @@ def c.rspec_puppet_include(group, type, file_path) c.rspec_puppet_include RSpec::Puppet::TypeExampleGroup, :type, %w[spec types] c.rspec_puppet_include RSpec::Puppet::TypeAliasExampleGroup, :type_alias, %w[spec type_aliases] c.rspec_puppet_include RSpec::Puppet::ProviderExampleGroup, :provider, %w[spec providers] - c.rspec_puppet_include RSpec::Puppet::ApplicationExampleGroup, :application, %w[spec applications] # Hook for each example group type to remove any caches or instance variables, since they will remain # and cause a memory leak. Can't be assigned per type by :file_path, so check for its presence. diff --git a/lib/rspec-puppet/example/application_example_group.rb b/lib/rspec-puppet/example/application_example_group.rb deleted file mode 100644 index 5d6b4ba8e..000000000 --- a/lib/rspec-puppet/example/application_example_group.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -module RSpec::Puppet - # This module provides support for the application type - module ApplicationExampleGroup - include RSpec::Puppet::ManifestMatchers - include RSpec::Puppet::Support - - def catalogue - @catalogue ||= load_catalogue(:application) - end - - def exported_resources - -> { load_catalogue(:application, true) } - end - - def rspec_puppet_cleanup - @catalogue = nil - end - end -end diff --git a/lib/rspec-puppet/support.rb b/lib/rspec-puppet/support.rb index ec7ef5947..69fcb5e5f 100644 --- a/lib/rspec-puppet/support.rb +++ b/lib/rspec-puppet/support.rb @@ -44,8 +44,6 @@ def guess_type_from_path(path) :type_alias when %r{spec/provider} :provider - when %r{spec/applications} - :application else :unknown end @@ -177,11 +175,6 @@ def test_manifest(type, opts = {}) else "class { '#{class_name}': #{param_str(opts[:params])} }" end - when :application - raise ArgumentError, 'You need to provide params for an application' unless opts.key?(:params) - - "site { #{class_name} { #{sanitise_resource_title(title)}: #{param_str(opts[:params])} } }" - when :define title_str = if title.is_a?(Array) '[' + title.map { |r| sanitise_resource_title(r) }.join(', ') + ']' @@ -207,7 +200,7 @@ def sanitise_resource_title(title) def nodename(type) return node if respond_to?(:node) - if %i[class define function application].include? type + if %i[class define function].include? type Puppet[:certname] else class_name diff --git a/spec/fixtures/modules/orch_app/manifests/db.pp b/spec/fixtures/modules/orch_app/manifests/db.pp deleted file mode 100644 index cf11eccca..000000000 --- a/spec/fixtures/modules/orch_app/manifests/db.pp +++ /dev/null @@ -1,3 +0,0 @@ -define orch_app::db( -) { -} diff --git a/spec/fixtures/modules/orch_app/manifests/init.pp b/spec/fixtures/modules/orch_app/manifests/init.pp deleted file mode 100644 index e79164f76..000000000 --- a/spec/fixtures/modules/orch_app/manifests/init.pp +++ /dev/null @@ -1,6 +0,0 @@ -application orch_app ( - String $mystring, -) { - orch_app::db { $name: - } -}